Class: QgsGradientStopEditor

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

Class Hierarchy

Inheritance diagram of qgis.gui.QgsGradientStopEditor

Base classes

QWidget

QObject

QPaintDevice

Methods

deleteSelectedStop

Deletes the current selected stop.

gradientRamp

Returns the current ramp created by the editor.

selectStop

Sets the currently selected stop.

selectedStop

Returns details about the currently selected stop.

setColor1

Sets the color for the first stop.

setColor2

Sets the color for the last stop.

setGradientRamp

Sets the current ramp shown in the editor.

setSelectedStopColor

Sets the color for the current selected stop.

setSelectedStopColorSpec

Sets the color spec for the current selected stop.

setSelectedStopDetails

Sets the color and offset for the current selected stop.

setSelectedStopDirection

Sets the hue angular direction for the current selected stop.

setSelectedStopOffset

Sets the offset for the current selected stop.

Signals

changed

Emitted when the gradient ramp is changed by a user

selectedStopChanged

Emitted when the current selected stop changes.

class qgis.gui.QgsGradientStopEditor[source]

Bases: QWidget

__init__(parent: QWidget | None = None, ramp: QgsGradientColorRamp | None = None)

Constructor for QgsGradientStopEditor.

Parameters:
  • parent (Optional[QWidget] = None) – parent widget

  • ramp (Optional[QgsGradientColorRamp] = None) – optional initial gradient ramp

signal changed[source]

Emitted when the gradient ramp is changed by a user

deleteSelectedStop(self)[source]

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

gradientRamp(self) QgsGradientColorRamp[source]

Returns the current ramp created by the editor.

Return type:

QgsGradientColorRamp

selectStop(self, index: int)[source]

Sets the currently selected stop.

Parameters:

index (int) – index of stop, where 0 corresponds to the first stop

See also

selectedStop()

selectedStop(self) QgsGradientStop[source]

Returns details about the currently selected stop.

See also

selectStop()

Return type:

QgsGradientStop

signal selectedStopChanged(stop: QgsGradientStop)[source]

Emitted when the current selected stop changes.

Parameters:

stop (QgsGradientStop) – details about newly selected stop

setColor1(self, color: QColor | Qt.GlobalColor)[source]

Sets the color for the first stop.

Parameters:

color (Union[QColor, Qt.GlobalColor]) – new stop color

See also

setColor2()

setColor2(self, color: QColor | Qt.GlobalColor)[source]

Sets the color for the last stop.

Parameters:

color (Union[QColor, Qt.GlobalColor]) – new stop color

See also

setColor1()

setGradientRamp(self, ramp: QgsGradientColorRamp)[source]

Sets the current ramp shown in the editor.

Parameters:

ramp (QgsGradientColorRamp) – color ramp

See also

gradientRamp()

setSelectedStopColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the color for the current selected stop.

Parameters:

color (Union[QColor, Qt.GlobalColor]) – new stop color

See also

setColor1()

See also

setColor2()

setSelectedStopColorSpec(self, spec: QColor.Spec)[source]

Sets the color spec for the current selected stop.

Added in version 3.24.

Parameters:

spec (QColor.Spec)

setSelectedStopDetails(self, color: QColor | Qt.GlobalColor, offset: float)[source]

Sets the color and offset for the current selected stop.

Parameters:
  • color (Union[QColor, Qt.GlobalColor]) – new stop color

  • offset (float) – new stop offset

setSelectedStopDirection(self, direction: Qgis.AngularDirection)[source]

Sets the hue angular direction for the current selected stop.

Added in version 3.24.

Parameters:

direction (Qgis.AngularDirection)

setSelectedStopOffset(self, offset: float)[source]

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

Parameters:

offset (float) – new stop offset