Class: QgsCompoundColorWidget

A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel, color swatches, and a color sampler.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsCompoundColorWidget

Base classes

QgsPanelWidget

Base class for any widget that can be shown as a inline panel

QWidget

QObject

QPaintDevice

Methods

color

Returns the current color for the dialog

setAllowOpacity

Sets whether opacity modification (transparency) is permitted for the color dialog.

setColor

Sets the current color for the dialog

setColorModelEditable

Sets whether color model is editable or not

setDiscarded

Sets whether the widget's color has been "discarded" and the selected color should not be stored in the recent color list.

setPreviousColor

Sets the color to show in an optional "previous color" section

Static Methods

createNewUserPalette

Triggers a user prompt for creating a new user color scheme.

importUserPaletteFromFile

Triggers a user prompt for importing a new color scheme from an existing GPL file.

removeUserPalette

Triggers a user prompt for removing an existing user color scheme.

Signals

currentColorChanged

Emitted when the dialog's color changes

Attributes

LayoutDefault

LayoutVertical

class qgis.gui.QgsCompoundColorWidget[source]

Bases: QgsPanelWidget

__init__(parent: QWidget | None = None, color: QColor | Qt.GlobalColor = QColor(), layout: QgsCompoundColorWidget.Layout = QgsCompoundColorWidget.LayoutDefault)

Constructor for QgsCompoundColorWidget

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

  • color (Union[QColor, Qt.GlobalColor] = QColor()) – initial color for dialog

  • layout (QgsCompoundColorWidget.Layout = QgsCompoundColorWidget.LayoutDefault) – widget layout to use

class Layout

Bases: int

LayoutDefault = 0
LayoutVertical = 1
color(self) QColor[source]

Returns the current color for the dialog

Return type:

QColor

Returns:

dialog color

static createNewUserPalette(parent: QWidget | None) QgsUserColorScheme | None[source]

Triggers a user prompt for creating a new user color scheme.

The parent argument must be set to a valid parent widget for the dialog prompts.

Added in version 3.2.

Parameters:

parent (Optional[QWidget])

Return type:

Optional[QgsUserColorScheme]

signal currentColorChanged(color: QColor)[source]

Emitted when the dialog’s color changes

Parameters:

color (QColor) – current color

static importUserPaletteFromFile(parent: QWidget | None) QgsUserColorScheme | None[source]

Triggers a user prompt for importing a new color scheme from an existing GPL file.

The parent argument must be set to a valid parent widget for the dialog prompts.

Added in version 3.2.

Parameters:

parent (Optional[QWidget])

Return type:

Optional[QgsUserColorScheme]

static removeUserPalette(scheme: QgsUserColorScheme | None, parent: QWidget | None) bool[source]

Triggers a user prompt for removing an existing user color scheme.

The parent argument must be set to a valid parent widget for the dialog prompts.

Added in version 3.2.

Parameters:
Return type:

bool

setAllowOpacity(self, allowOpacity: bool)[source]

Sets whether opacity modification (transparency) is permitted for the color dialog. Defaults to True.

Parameters:

allowOpacity (bool) – set to False to disable opacity modification

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

Sets the current color for the dialog

Parameters:

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

setColorModelEditable(self, colorModelEditable: bool)[source]

Sets whether color model is editable or not

Parameters:

colorModelEditable (bool) – set to False to disable color model modification Defaults to True.

Added in version 3.40.

setDiscarded(self, discarded: bool)[source]

Sets whether the widget’s color has been “discarded” and the selected color should not be stored in the recent color list.

Parameters:

discarded (bool) – set to True to avoid adding color to recent color list on widget destruction.

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

Sets the color to show in an optional “previous color” section

Parameters:

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