QgsColorRampWidget class

A color ramp widget.

This widget consists of an interactive box filled with a color which varies along its length by a single color component (e.g., varying saturation from 0 to 100%).

Base classes

class QgsColorWidget
A base class for interactive color widgets.

Public types

enum Orientation { Horizontal = 0, Vertical }
Specifies the orientation of a color ramp.

Constructors, destructors, conversion operators

QgsColorRampWidget(QWidget* parent = nullptr, ColorComponent component = QgsColorWidget::Red, Orientation orientation = QgsColorRampWidget::Horizontal)
Construct a new color ramp widget.

Public functions

auto interiorMargin() const -> int
Fetches the margin between the edge of the widget and the ramp.
auto orientation() const -> Orientation
Fetches the orientation for the color ramp.
void setInteriorMargin(int margin)
Sets the margin between the edge of the widget and the ramp.
void setMarkerSize(int markerSize)
Sets the size for drawing the triangular markers on the ramp.
void setOrientation(Orientation orientation)
Sets the orientation for the color ramp.
void setShowFrame(bool showFrame)
Sets whether the ramp should be drawn within a frame.
auto showFrame() const -> bool
Fetches whether the ramp is drawn within a frame.

Signals

void valueChanged(int value)
Emitted when the widget's color component value changes.

Enum documentation

enum QgsColorRampWidget::Orientation

Specifies the orientation of a color ramp.

Enumerators
Horizontal

Horizontal ramp.

Vertical

Vertical ramp.

Function documentation

QgsColorRampWidget::QgsColorRampWidget(QWidget* parent = nullptr, ColorComponent component = QgsColorWidget::Red, Orientation orientation = QgsColorRampWidget::Horizontal)

Construct a new color ramp widget.

Parameters
parent parent QWidget for the widget
component color component which varies along the ramp
orientation orientation for widget

int QgsColorRampWidget::interiorMargin() const

Fetches the margin between the edge of the widget and the ramp.

Returns margin around the ramp

Orientation QgsColorRampWidget::orientation() const

Fetches the orientation for the color ramp.

Returns orientation for the ramp

void QgsColorRampWidget::setInteriorMargin(int margin)

Sets the margin between the edge of the widget and the ramp.

Parameters
margin margin around the ramp

void QgsColorRampWidget::setMarkerSize(int markerSize)

Sets the size for drawing the triangular markers on the ramp.

Parameters
markerSize marker size in pixels

void QgsColorRampWidget::setOrientation(Orientation orientation)

Sets the orientation for the color ramp.

Parameters
orientation new orientation for the ramp

void QgsColorRampWidget::setShowFrame(bool showFrame)

Sets whether the ramp should be drawn within a frame.

Parameters
showFrame set to true to draw a frame around the ramp

bool QgsColorRampWidget::showFrame() const

Fetches whether the ramp is drawn within a frame.

Returns true if a frame is drawn around the ramp

void QgsColorRampWidget::valueChanged(int value) signal

Emitted when the widget's color component value changes.

Parameters
value new value of color component