QColorDialog

Synopsis

Functions

Signals

Static functions

Detailed Description

The PySide.QtGui.QColorDialog class provides a dialog widget for specifying colors.

The color dialog’s function is to allow users to choose colors. For example, you might use this in a drawing program to allow the user to set the brush color.

The static functions provide modal color dialogs.

The static PySide.QtGui.QColorDialog.getColor() function shows the dialog, and allows the user to specify a color. This function can also be used to let users choose a color with a level of transparency: pass the ShowAlphaChannel option as an additional argument.

The user can store PySide.QtGui.QColorDialog.customCount() different custom colors. The custom colors are shared by all color dialogs, and remembered during the execution of the program. Use PySide.QtGui.QColorDialog.setCustomColor() to set the custom colors, and use PySide.QtGui.QColorDialog.customColor() to get them.

The Standard Dialogs example shows how to use PySide.QtGui.QColorDialog as well as other built-in Qt dialogs.

../../_images/plastique-colordialog.png
class PySide.QtGui.QColorDialog([parent=None])
class PySide.QtGui.QColorDialog(initial[, parent=None])
Parameters:

Constructs a color dialog with the given parent .

Constructs a color dialog with the given parent and specified initial color.

PySide.QtGui.QColorDialog.ColorDialogOption

This enum specifies various options that affect the look and feel of a color dialog.

Constant Description
QColorDialog.ShowAlphaChannel Allow the user to select the alpha component of a color.
QColorDialog.NoButtons Don’t display OK and Cancel buttons. (Useful for “live dialogs”.)
QColorDialog.DontUseNativeDialog Use Qt’s standard color dialog on the Mac instead of Apple’s native color panel.
PySide.QtGui.QColorDialog.colorSelected(color)
Parameters:colorPySide.QtGui.QColor
PySide.QtGui.QColorDialog.currentColor()
Return type:PySide.QtGui.QColor

This property holds the currently selected color in the dialog.

PySide.QtGui.QColorDialog.currentColorChanged(color)
Parameters:colorPySide.QtGui.QColor
static PySide.QtGui.QColorDialog.customColor(index)
Parameters:indexPySide.QtCore.int
Return type:long

Returns the custom color at the given index as a QRgb value.

static PySide.QtGui.QColorDialog.customCount()
Return type:PySide.QtCore.int

Returns the number of custom colors supported by PySide.QtGui.QColorDialog . All color dialogs share the same custom colors.

static PySide.QtGui.QColorDialog.getColor(initial, parent, title[, options=0])
Parameters:
Return type:

PySide.QtGui.QColor

static PySide.QtGui.QColorDialog.getColor([initial=Qt.white[, parent=None]])
Parameters:
Return type:

PySide.QtGui.QColor

Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to initial . The dialog is a child of parent . It returns an invalid (see QColor.isValid() ) color if the user cancels the dialog.

On Symbian, this static function will use the native color dialog and not a PySide.QtGui.QColorDialog .

PySide.QtGui.QColorDialog.open(receiver, member)
Parameters:

This is an overloaded function.

Opens the dialog and connects its PySide.QtGui.QColorDialog.colorSelected() signal to the slot specified by receiver and member .

The signal will be disconnected from the slot when the dialog is closed.

PySide.QtGui.QColorDialog.options()
Return type:PySide.QtGui.QColorDialog.ColorDialogOptions

This property holds the various options that affect the look and feel of the dialog.

By default, all options are disabled.

Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).

PySide.QtGui.QColorDialog.selectedColor()
Return type:PySide.QtGui.QColor

Returns the color that the user selected by clicking the OK or equivalent button.

Note

This color is not always the same as the color held by the PySide.QtGui.QColorDialog.currentColor() property since the user can choose different colors before finally selecting the one to use.

PySide.QtGui.QColorDialog.setCurrentColor(color)
Parameters:colorPySide.QtGui.QColor
static PySide.QtGui.QColorDialog.setCustomColor(index, color)
Parameters:
  • indexPySide.QtCore.int
  • color – long
PySide.QtGui.QColorDialog.setOption(option[, on=true])
Parameters:

Sets the given option to be enabled if on is true; otherwise, clears the given option .

PySide.QtGui.QColorDialog.setOptions(options)
Parameters:optionsPySide.QtGui.QColorDialog.ColorDialogOptions

This property holds the various options that affect the look and feel of the dialog.

By default, all options are disabled.

Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).

static PySide.QtGui.QColorDialog.setStandardColor(index, color)
Parameters:
  • indexPySide.QtCore.int
  • color – long
PySide.QtGui.QColorDialog.testOption(option)
Parameters:optionPySide.QtGui.QColorDialog.ColorDialogOption
Return type:PySide.QtCore.bool

Returns true if the given option is enabled; otherwise, returns false.