Class: QgsColorDialog

A custom QGIS dialog for selecting a color.

Has many improvements over the standard Qt color picker dialog, including hue wheel supports, color swatches, and a color sampler.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorDialog

Base classes

QDialog

QWidget

QObject

QPaintDevice

class qgis.gui.QgsColorDialog[source]

Bases: QDialog

__init__(parent: QWidget | None = None, fl: Qt.WindowFlags | Qt.WindowType = QgsGuiUtils.ModalDialogFlags, color: QColor | Qt.GlobalColor = QColor())

Create a new color picker dialog

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

  • fl (Union[Qt.WindowFlags, Qt.WindowType] = QgsGuiUtils.ModalDialogFlags) – window flags

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

color(self) QColor[source]

Returns the current color for the dialog

Return type:

QColor

Returns:

dialog color

signal currentColorChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

static getColor(initialColor: QColor | Qt.GlobalColor, parent: QWidget | None, title: str | None = '', allowOpacity: bool = False) QColor[source]

Returns a color selection from a color dialog.

Parameters:
  • initialColor (Union[QColor, Qt.GlobalColor]) – the initial color of the selection dialog.

  • parent (Optional[QWidget]) – parent widget

  • title (Optional[str] = '') – the title of the dialog.

  • allowOpacity (bool = False) – set to True to allow modification of color opacity value (transparency)

Return type:

QColor

Returns:

Selected color on accepted() or initialColor on rejected().

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

setTitle(self, title: str | None)[source]

Sets the title for the color dialog

Parameters:

title (Optional[str]) – title for dialog box