Subgroup: Color

Class: QgsColorDialog

class qgis.gui.QgsColorDialog(parent: QWidget = None, fl: Union[Qt.WindowFlags, Qt.WindowType] = QgsGuiUtils.ModalDialogFlags, color: Union[QColor, Qt.GlobalColor, QGradient] = QColor())

Bases: PyQt5.QtWidgets.QDialog

Create a new color picker dialog

Parameters:
  • parent – parent widget
  • fl – window flags
  • color – initial color for dialog

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.

actionEvent()
changeEvent()
childEvent()
closeEvent(self, e: QCloseEvent)
color(self) → QColor

Returns the current color for the dialog

Returns:dialog color
connectNotify()
contextMenuEvent()
create()
currentColorChanged

Emitted when the dialog’s color changes

Parameters:color – current color [signal]
customEvent()
destroy()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
enterEvent()
event()
eventFilter()
focusInEvent()
focusNextChild()
focusNextPrevChild()
focusOutEvent()
focusPreviousChild()
getColor(initialColor: Union[QColor, Qt.GlobalColor, QGradient], parent: QWidget, title: str = '', allowOpacity: bool = False) → QColor

Return a color selection from a color dialog.

Parameters:
  • initialColor – the initial color of the selection dialog.
  • parent – parent widget
  • title – the title of the dialog.
  • allowOpacity – set to true to allow modification of color opacity value (transparency)
Returns:

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

See also

getLiveColor()

hideEvent()
initPainter()
inputMethodEvent()
isSignalConnected()
keyPressEvent()
keyReleaseEvent()
leaveEvent()
metric()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveEvent()
nativeEvent()
paintEvent()
receivers()
resizeEvent()
sender()
senderSignalIndex()
setAllowOpacity(self, allowOpacity: bool)

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

Parameters:allowOpacity – set to false to disable opacity modification

New in version 3.0.

setColor(self, color: Union[QColor, Qt.GlobalColor, QGradient])

Sets the current color for the dialog

Parameters:color – desired color
setTitle(self, title: str)

Sets the title for the color dialog

Parameters:title – title for dialog box
sharedPainter()
showEvent()
tabletEvent()
timerEvent()
updateMicroFocus()
wheelEvent()