<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QColorDialog Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QColorDialog Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QColorDialog class provides a dialog widget for specifying colors. <a href="#details">More...</a></p> <p>Inherits <a href="qdialog.html">QDialog</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qcolordialog.html#ColorDialogOption-enum">ColorDialogOption</a></b> { ShowAlphaChannel, NoButtons, DontUseNativeDialog }</li><li><div class="fn" />class <b><a href="qcolordialog-colordialogoptions.html">ColorDialogOptions</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qcolordialog.html#QColorDialog">__init__</a></b> (<i>self</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qcolordialog.html#QColorDialog-2">__init__</a></b> (<i>self</i>, QColor <i>initial</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qcolordialog.html#changeEvent">changeEvent</a></b> (<i>self</i>, QEvent <i>e</i>)</li><li><div class="fn" />QColor <b><a href="qcolordialog.html#currentColor">currentColor</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#done">done</a></b> (<i>self</i>, int <i>result</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#open">open</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#open-2">open</a></b> (<i>self</i>, QObject <i>receiver</i>, SLOT()SLOT() <i>member</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#open-3">open</a></b> (<i>self</i>, callable <i>receiver</i>)</li><li><div class="fn" />ColorDialogOptions <b><a href="qcolordialog.html#options">options</a></b> (<i>self</i>)</li><li><div class="fn" />QColor <b><a href="qcolordialog.html#selectedColor">selectedColor</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#setCurrentColor">setCurrentColor</a></b> (<i>self</i>, QColor <i>color</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#setOption">setOption</a></b> (<i>self</i>, ColorDialogOption <i>option</i>, bool <i>on</i> = True)</li><li><div class="fn" /><b><a href="qcolordialog.html#setOptions">setOptions</a></b> (<i>self</i>, ColorDialogOptions <i>options</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#setVisible">setVisible</a></b> (<i>self</i>, bool <i>visible</i>)</li><li><div class="fn" />bool <b><a href="qcolordialog.html#testOption">testOption</a></b> (<i>self</i>, ColorDialogOption <i>option</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />int <b><a href="qcolordialog.html#customColor">customColor</a></b> (int)</li><li><div class="fn" />int <b><a href="qcolordialog.html#customCount">customCount</a></b> ()</li><li><div class="fn" />QColor <b><a href="qcolordialog.html#getColor">getColor</a></b> (QColor <i>initial</i> = Qt.white, QWidget <i>parent</i> = None)</li><li><div class="fn" />QColor <b><a href="qcolordialog.html#getColor-2">getColor</a></b> (QColor <i>initial</i>, QWidget <i>parent</i>, QString <i>title</i>, ColorDialogOptions <i>options</i> = 0)</li><li><div class="fn" />(int, bool <i>ok</i>) <b><a href="qcolordialog.html#getRgba">getRgba</a></b> (int <i>initial</i> = 4294967295, QWidget <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qcolordialog.html#setCustomColor">setCustomColor</a></b> (int, int)</li><li><div class="fn" /><b><a href="qcolordialog.html#setStandardColor">setStandardColor</a></b> (int, int)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qcolordialog.html#colorSelected">colorSelected</a></b> (const QColor&)</li><li><div class="fn" />void <b><a href="qcolordialog.html#currentColorChanged">currentColorChanged</a></b> (const QColor&)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QColorDialog class provides a dialog widget for specifying colors.</p> <p>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.</p> <p>The static functions provide modal color dialogs.</p> <p>The static <a href="qcolordialog.html#getColor">getColor</a>() 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 <a href="qcolordialog.html#ColorDialogOption-enum">ShowAlphaChannel</a> option as an additional argument.</p> <p>The user can store <a href="qcolordialog.html#customCount">customCount</a>() different custom colors. The custom colors are shared by all color dialogs, and remembered during the execution of the program. Use <a href="qcolordialog.html#setCustomColor">setCustomColor</a>() to set the custom colors, and use <a href="qcolordialog.html#customColor">customColor</a>() to get them.</p> <p>The <a href="dialogs-standarddialogs.html">Standard Dialogs</a> example shows how to use QColorDialog as well as other built-in Qt dialogs.</p> <p class="centerAlign"><img alt="A color dialog in the Plastique widget style." src="images/plastique-colordialog.png" /></p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="ColorDialogOption-enum" />QColorDialog.ColorDialogOption</h3><p>This enum specifies various options that affect the look and feel of a color dialog.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QColorDialog.ShowAlphaChannel</tt></td> <td class="topAlign"><tt>0x00000001</tt></td> <td class="topAlign">Allow the user to select the alpha component of a color.</td> </tr> <tr> <td class="topAlign"><tt>QColorDialog.NoButtons</tt></td> <td class="topAlign"><tt>0x00000002</tt></td> <td class="topAlign">Don't display <b>OK</b> and <b>Cancel</b> buttons. (Useful for "live dialogs".)</td> </tr> <tr> <td class="topAlign"> <tt>QColorDialog.DontUseNativeDialog</tt></td> <td class="topAlign"><tt>0x00000004</tt></td> <td class="topAlign">Use Qt's standard color dialog on the Mac instead of Apple's native color panel.</td> </tr> </table> <p>This enum was introduced or modified in Qt 4.5.</p> <p>The ColorDialogOptions type is a typedef for <a href="qflags.html">QFlags</a><ColorDialogOption>. It stores an OR combination of ColorDialogOption values.</p> <p><b>See also</b> <a href="qcolordialog.html#options-prop">options</a>, <a href="qcolordialog.html#setOption">setOption</a>(), <a href="qcolordialog.html#testOption">testOption</a>(), and <a href="qwidget.html#windowModality-prop">windowModality</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QColorDialog" />QColorDialog.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a color dialog with the given <i>parent</i>.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="QColorDialog-2" />QColorDialog.__init__ (<i>self</i>, <a href="qcolor.html">QColor</a> <i>initial</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a color dialog with the given <i>parent</i> and specified <i>initial</i> color.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="changeEvent" />QColorDialog.changeEvent (<i>self</i>, <a href="qevent.html">QEvent</a> <i>e</i>)</h3><p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget.changeEvent</a>().</p> <h3 class="fn"><a name="currentColor" /><a href="qcolor.html">QColor</a> QColorDialog.currentColor (<i>self</i>)</h3><h3 class="fn"><a name="customColor" />int QColorDialog.customColor (int)</h3><p>Returns the custom color at the given <i>index</i> as a <a href="qcolor.html#QRgb-typedef">QRgb</a> value.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qcolordialog.html#setCustomColor">setCustomColor</a>().</p> <h3 class="fn"><a name="customCount" />int QColorDialog.customCount ()</h3><p>Returns the number of custom colors supported by <a href="qcolordialog.html">QColorDialog</a>. All color dialogs share the same custom colors.</p> <h3 class="fn"><a name="done" />QColorDialog.done (<i>self</i>, int <i>result</i>)</h3><p>Reimplemented from <a href="qdialog.html#done">QDialog.done</a>().</p> <p>Closes the dialog and sets its result code to <i>result</i>. If this dialog is shown with <a href="qdialog.html#exec">exec_</a>(), done() causes the local event loop to finish, and <a href="qdialog.html#exec">exec_</a>() to return <i>result</i>.</p> <p><b>See also</b> <a href="qdialog.html#done">QDialog.done</a>().</p> <h3 class="fn"><a name="getColor" /><a href="qcolor.html">QColor</a> QColorDialog.getColor (<a href="qcolor.html">QColor</a> <i>initial</i> = Qt.white, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>Pops up a modal color dialog with the given window <i>title</i> (or "Select Color" if none is specified), lets the user choose a color, and returns that color. The color is initially set to <i>initial</i>. The dialog is a child of <i>parent</i>. It returns an invalid (see <a href="qcolor.html#isValid">QColor.isValid</a>()) color if the user cancels the dialog.</p> <p>The <i>options</i> argument allows you to customize the dialog.</p> <p>On Symbian, this static function will use the native color dialog and not a <a href="qcolordialog.html">QColorDialog</a>. On Symbian the parameters <i>title</i> and <i>parent</i> has no relevance and the <i>options</i> parameter is only used to define if the native color dialog is used or not.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="getColor-2" /><a href="qcolor.html">QColor</a> QColorDialog.getColor (<a href="qcolor.html">QColor</a> <i>initial</i>, <a href="qwidget.html">QWidget</a> <i>parent</i>, QString <i>title</i>, <a href="qcolordialog-colordialogoptions.html">ColorDialogOptions</a> <i>options</i> = 0)</h3><p>Pops up a modal color dialog, lets the user choose a color, and returns that color. The color is initially set to <i>initial</i>. The dialog is a child of <i>parent</i>. It returns an invalid (see <a href="qcolor.html#isValid">QColor.isValid</a>()) color if the user cancels the dialog.</p> <p>On Symbian, this static function will use the native color dialog and not a <a href="qcolordialog.html">QColorDialog</a>.</p> <h3 class="fn"><a name="getRgba" />(int, bool <i>ok</i>) QColorDialog.getRgba (int <i>initial</i> = 4294967295, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><h3 class="fn"><a name="open" />QColorDialog.open (<i>self</i>)</h3><p>Shows the dialog as a <a href="qdialog.html#modal-dialogs">window modal dialog</a>, returning immediately.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qdialog.html#open">QDialog.open</a>().</p> <h3 class="fn"><a name="open-2" />QColorDialog.open (<i>self</i>, <a href="qobject.html">QObject</a> <i>receiver</i>, SLOT()SLOT() <i>member</i>)</h3><p>This is an overloaded function.</p> <p>Opens the dialog and connects its <a href="qcolordialog.html#colorSelected">colorSelected</a>() signal to the slot specified by <i>receiver</i> and <i>member</i>.</p> <p>The signal will be disconnected from the slot when the dialog is closed.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="open-3" />QColorDialog.open (<i>self</i>, callable <i>receiver</i>)</h3><h3 class="fn"><a name="options" /><a href="qcolordialog-colordialogoptions.html">ColorDialogOptions</a> QColorDialog.options (<i>self</i>)</h3><h3 class="fn"><a name="selectedColor" /><a href="qcolor.html">QColor</a> QColorDialog.selectedColor (<i>self</i>)</h3><p>Returns the color that the user selected by clicking the <b>OK</b> or equivalent button.</p> <p><b>Note:</b> This color is not always the same as the color held by the <a href="qcolordialog.html#currentColor-prop">currentColor</a> property since the user can choose different colors before finally selecting the one to use.</p> <h3 class="fn"><a name="setCurrentColor" />QColorDialog.setCurrentColor (<i>self</i>, <a href="qcolor.html">QColor</a> <i>color</i>)</h3><h3 class="fn"><a name="setCustomColor" />QColorDialog.setCustomColor (int, int)</h3><p>Sets the custom color at <i>index</i> to the <a href="qcolor.html#QRgb-typedef">QRgb</a> <i>color</i> value.</p> <p><b>Note:</b> This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the <a href="qcolordialog.html#ColorDialogOption-enum">QColorDialog.DontUseNativeDialog</a> option.</p> <p><b>See also</b> <a href="qcolordialog.html#customColor">customColor</a>().</p> <h3 class="fn"><a name="setOption" />QColorDialog.setOption (<i>self</i>, <a href="qcolordialog.html#ColorDialogOption-enum">ColorDialogOption</a> <i>option</i>, bool <i>on</i> = True)</h3><p>Sets the given <i>option</i> to be enabled if <i>on</i> is true; otherwise, clears the given <i>option</i>.</p> <p><b>See also</b> <a href="qcolordialog.html#options-prop">options</a> and <a href="qcolordialog.html#testOption">testOption</a>().</p> <h3 class="fn"><a name="setOptions" />QColorDialog.setOptions (<i>self</i>, <a href="qcolordialog-colordialogoptions.html">ColorDialogOptions</a> <i>options</i>)</h3><h3 class="fn"><a name="setStandardColor" />QColorDialog.setStandardColor (int, int)</h3><p>Sets the standard color at <i>index</i> to the <a href="qcolor.html#QRgb-typedef">QRgb</a> <i>color</i> value.</p> <p><b>Note:</b> This function does not apply to the Native Color Dialog on the Mac OS X platform. If you still require this function, use the <a href="qcolordialog.html#ColorDialogOption-enum">QColorDialog.DontUseNativeDialog</a> option.</p> <h3 class="fn"><a name="setVisible" />QColorDialog.setVisible (<i>self</i>, bool <i>visible</i>)</h3><p>Reimplemented from <a href="qwidget.html#visible-prop">QWidget.setVisible</a>().</p> <p>Changes the visibility of the dialog. If <i>visible</i> is true, the dialog is shown; otherwise, it is hidden.</p> <h3 class="fn"><a name="testOption" />bool QColorDialog.testOption (<i>self</i>, <a href="qcolordialog.html#ColorDialogOption-enum">ColorDialogOption</a> <i>option</i>)</h3><p>Returns true if the given <i>option</i> is enabled; otherwise, returns false.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qcolordialog.html#options-prop">options</a> and <a href="qcolordialog.html#setOption">setOption</a>().</p> <hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="colorSelected" />void colorSelected (const QColor&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted just after the user has clicked <b>OK</b> to select a color to use. The chosen color is specified by <i>color</i>.</p> <p><b>See also</b> <a href="qml-color.html">color</a> and <a href="qcolordialog.html#currentColorChanged">currentColorChanged</a>().</p> <h3 class="fn"><a name="currentColorChanged" />void currentColorChanged (const QColor&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the current color changes in the dialog. The current color is specified by <i>color</i>.</p> <p><b>See also</b> <a href="qml-color.html">color</a> and <a href="qcolordialog.html#colorSelected">colorSelected</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>