Class: QgsColorWidgetAction

An action containing a color widget, which can be embedded into a menu.

See also

QgsColorWidget

List of all members, including inherited members

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorWidgetAction

Base classes

QWidgetAction

QAction

QObject

Constructor

__init__

Methods

colorWidget

Returns the color widget contained in the widget action.

dismissOnColorSelection

Returns whether the parent menu will be dismissed after a color is selected from the action's color widget.

setDismissOnColorSelection

Sets whether the parent menu should be dismissed and closed when a color is selected from the action's color widget.

Signals

colorChanged

Emitted when a color has been selected from the widget

class qgis.gui.QgsColorWidgetAction[source]

Bases: QWidgetAction

__init__(colorWidget: QgsColorWidget | None, menu: QMenu | None = None, parent: QWidget | None = None)

Construct a new color widget action.

Parameters:
  • colorWidget (Optional[QgsColorWidget]) – QgsColorWidget to show in action

  • menu (Optional[QMenu] = None) – parent menu

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

signal colorChanged(color: QColor)[source]

Emitted when a color has been selected from the widget

Parameters:

color (QColor) – selected color

colorWidget(self) QgsColorWidget | None[source]

Returns the color widget contained in the widget action.

Return type:

Optional[QgsColorWidget]

dismissOnColorSelection(self) bool[source]

Returns whether the parent menu will be dismissed after a color is selected from the action’s color widget.

Return type:

bool

setDismissOnColorSelection(self, dismiss: bool)[source]

Sets whether the parent menu should be dismissed and closed when a color is selected from the action’s color widget.

Parameters:

dismiss (bool) – set to True (default) to immediately close the menu when a color is selected from the widget. If set to False, the colorChanged signal will be emitted but the menu will stay open.