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¶
Base classes¶
Methods
Returns the current color for the dialog |
|
Sets whether opacity modification (transparency) is permitted for the color dialog. |
|
Sets the current color for the dialog |
|
Sets the title for the color dialog |
Static Methods
Returns a color selection from a color dialog. |
Signals
Emitted when the dialog's color changes |
- 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(color: QColor)[source]¶
Emitted when the dialog’s color changes
- Parameters:
color (QColor) – current color
- 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 onrejected()
.
- 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