Class: QgsColorPreviewWidget

A preview box which displays one or two colors as swatches.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorPreviewWidget

Base classes

QgsColorWidget

A base class for interactive color widgets. Widgets can either allow setting a single component of a color (e.g., the red or green components), or an entire color. The QgsColorWidget also keeps track of any explicitly set hue for the color, so that this information is not lost when the widget is set to a color with an ambiguous hue (e.g., black or white shades).

QWidget

QObject

QPaintDevice

Methods

color2

Returns the secondary color for the widget

setColor2

Sets the second color for the widget

class qgis.gui.QgsColorPreviewWidget[source]

Bases: QgsColorWidget

__init__(parent: QWidget | None = None)

Construct a new color preview widget.

Parameters:

parent (Optional[QWidget] = None) – parent QWidget for the widget

color2(self) QColor[source]

Returns the secondary color for the widget

Return type:

QColor

Returns:

secondary widget color, or an invalid color if the widget has no secondary color

See also

color()

See also

setColor2()

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

Sets the second color for the widget

Parameters:

color (Union[QColor, Qt.GlobalColor]) – secondary widget color. Set to an invalid color to prevent drawing of a secondary color

See also

setColor()

See also

color2()