|  | Home · All Classes · Modules

# QColorDialog Class Reference
[QtGui module]

The QColorDialog class provides a dialog widget for specifying colors. More...

Inherits QDialog.

### Methods

- changeEvent (self, QEvent e)

### Static Methods

- unsigned long customColor (int)
- int customCount ()
- QColor getColor (QColor init = Qt.white, QWidget parent = None)
- (unsigned long, bool ok) getRgba (unsigned long = 4294967295, QWidget parent = None)
- setCustomColor (int, unsigned long)
- setStandardColor (int, unsigned long)

## Detailed Description

The 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 getColor() function shows the dialog, and allows the user to specify a color. The getRgba() function does the same, but also allows the user to specify a color with an alpha channel (transparency) value.

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

Additional widgets that allow users to pick colors are available as Qt Solutions.

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

See also QColor, QFileDialog, QPrintDialog, QFontDialog, and Standard Dialogs Example.

## Method Documentation

### QColorDialog.changeEvent (self, QEvent e)

### unsigned long QColorDialog.customColor (int)

Returns custom color number i as a QRgb value.

See also setCustomColor().

### int QColorDialog.customCount ()

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

### QColor QColorDialog.getColor (QColor init = Qt.white, QWidget parent = None)

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. All colors allocated by the dialog will be deallocated before this function returns.

### (unsigned long, bool ok) QColorDialog.getRgba (unsigned long = 4294967295, QWidget parent = None)

Pops up a modal color dialog to allow the user to choose a color and an alpha channel (transparency) value. The color+alpha is initially set to initial. The dialog is a child of parent.

If ok is non-null, *a ok is set to true if the user clicked OK, and to false if the user clicked Cancel.

If the user clicks Cancel, the initial value is returned.

### QColorDialog.setCustomColor (int, unsigned long)

Sets the custom color number to the QRgb color value.

See also customColor().

### QColorDialog.setStandardColor (int, unsigned long)

Sets the standard color number to the QRgb color value given.