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.

QWidget

QObject

QPaintDevice

Methods

color2

Returns the secondary color for the widget

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsColorPreviewWidget. See the FAQ for more details.

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()

virtual 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()