File: qcolordialog.html

package info (click to toggle)
python-qt4 4.12.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 40,300 kB
  • ctags: 6,185
  • sloc: python: 125,988; cpp: 13,291; xml: 292; makefile: 246; php: 27; sh: 2
file content (178 lines) | stat: -rw-r--r-- 17,343 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?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">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <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&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qcolordialog.html#QColorDialog-2">__init__</a></b> (<i>self</i>, QColor&#160;<i>initial</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qcolordialog.html#changeEvent">changeEvent</a></b> (<i>self</i>, QEvent&#160;<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&#160;<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&#160;<i>receiver</i>, object&#160;<i>member</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#open-3">open</a></b> (<i>self</i>, object&#160;<i>slot</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&#160;<i>color</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#setOption">setOption</a></b> (<i>self</i>, ColorDialogOption&#160;<i>option</i>, bool&#160;<i>on</i>&#160;=&#160;True)</li><li><div class="fn" /><b><a href="qcolordialog.html#setOptions">setOptions</a></b> (<i>self</i>, ColorDialogOptions&#160;<i>options</i>)</li><li><div class="fn" /><b><a href="qcolordialog.html#setVisible">setVisible</a></b> (<i>self</i>, bool&#160;<i>visible</i>)</li><li><div class="fn" />bool <b><a href="qcolordialog.html#testOption">testOption</a></b> (<i>self</i>, ColorDialogOption&#160;<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&#160;<i>initial</i>&#160;=&#160;Qt.white, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QColor <b><a href="qcolordialog.html#getColor-2">getColor</a></b> (QColor&#160;<i>initial</i>, QWidget&#160;<i>parent</i>, QString&#160;<i>title</i>, ColorDialogOptions&#160;<i>options</i>&#160;=&#160;0)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qcolordialog.html#getRgba">getRgba</a></b> (int&#160;<i>initial</i>&#160;=&#160;4294967295, QWidget&#160;<i>parent</i>&#160;=&#160;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&amp;)</li><li><div class="fn" />void <b><a href="qcolordialog.html#currentColorChanged">currentColorChanged</a></b> (const  ::QColor&amp;)</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 the operating system native color dialog.</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>&lt;ColorDialogOption&gt;. 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>&#160;<i>parent</i>&#160;=&#160;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>&#160;<i>initial</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;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>&#160;<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&#160;<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>&#160;<i>initial</i>&#160;=&#160;Qt.white, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;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>&#160;<i>initial</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, QString&#160;<i>title</i>, <a href="qcolordialog-colordialogoptions.html">ColorDialogOptions</a>&#160;<i>options</i>&#160;=&#160;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&#160;<i>ok</i>) QColorDialog.getRgba (int&#160;<i>initial</i>&#160;=&#160;4294967295, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;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>&#160;<i>receiver</i>, object&#160;<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>, object&#160;<i>slot</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>&#160;<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>&#160;<i>option</i>, bool&#160;<i>on</i>&#160;=&#160;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>&#160;<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&#160;<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>&#160;<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&amp;)</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&amp;)</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&#160;4.12.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt&#160;4.8.7</td></tr></table></div></address></body></html>