QgsGradientStopEditor class

An interactive editor for previewing a gradient color ramp and modifying the position of color stops along the gradient.

Constructors, destructors, conversion operators

QgsGradientStopEditor(QWidget* parent = nullptr, QgsGradientColorRamp* ramp = nullptr)
Constructor for QgsGradientStopEditor.

Public functions

auto gradientRamp() const -> QgsGradientColorRamp
Returns the current ramp created by the editor.
auto selectedStop() const -> QgsGradientStop
Returns details about the currently selected stop.
void selectStop(int index)
Sets the currently selected stop.
void setGradientRamp(const QgsGradientColorRamp& ramp)
Sets the current ramp shown in the editor.

Signals

void changed()
Emitted when the gradient ramp is changed by a user.
void selectedStopChanged(const QgsGradientStop& stop)
Emitted when the current selected stop changes.

Public slots

void deleteSelectedStop()
Deletes the current selected stop.
void setColor1(const QColor& color)
Sets the color for the first stop.
void setColor2(const QColor& color)
Sets the color for the last stop.
void setSelectedStopColor(const QColor& color)
Sets the color for the current selected stop.
void setSelectedStopDetails(const QColor& color, double offset)
Sets the color and offset for the current selected stop.
void setSelectedStopOffset(double offset)
Sets the offset for the current selected stop.

Function documentation

QgsGradientStopEditor::QgsGradientStopEditor(QWidget* parent = nullptr, QgsGradientColorRamp* ramp = nullptr)

Constructor for QgsGradientStopEditor.

Parameters
parent parent widget
ramp optional initial gradient ramp

QgsGradientColorRamp QgsGradientStopEditor::gradientRamp() const

Returns the current ramp created by the editor.

QgsGradientStop QgsGradientStopEditor::selectedStop() const

Returns details about the currently selected stop.

void QgsGradientStopEditor::selectStop(int index)

Sets the currently selected stop.

Parameters
index index of stop, where 0 corresponds to the first stop

void QgsGradientStopEditor::setGradientRamp(const QgsGradientColorRamp& ramp)

Sets the current ramp shown in the editor.

Parameters
ramp color ramp

void QgsGradientStopEditor::selectedStopChanged(const QgsGradientStop& stop) signal

Emitted when the current selected stop changes.

Parameters
stop details about newly selected stop

void QgsGradientStopEditor::deleteSelectedStop() public slot

Deletes the current selected stop.

This slot has no effect if either the first or last stop is selected, as they cannot be deleted.

void QgsGradientStopEditor::setColor1(const QColor& color) public slot

Sets the color for the first stop.

Parameters
color new stop color

void QgsGradientStopEditor::setColor2(const QColor& color) public slot

Sets the color for the last stop.

Parameters
color new stop color

void QgsGradientStopEditor::setSelectedStopColor(const QColor& color) public slot

Sets the color for the current selected stop.

Parameters
color new stop color

void QgsGradientStopEditor::setSelectedStopDetails(const QColor& color, double offset) public slot

Sets the color and offset for the current selected stop.

Parameters
color new stop color
offset new stop offset

void QgsGradientStopEditor::setSelectedStopOffset(double offset) public slot

Sets the offset for the current selected stop.

Parameters
offset new stop offset

This slot has no effect if either the first or last stop is selected, as they cannot be repositioned.