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
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtcolorpicker-2.6_1-opensource/src/qtcolorpicker.cpp -->
<head>
<title>QtColorPicker Class Reference</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">QtColorPicker Class Reference</h1>
<p>The QtColorPicker class provides a widget for selecting colors from a popup color grid. <a href="#details">More...</a></p>
<pre> #include <QtColorPicker></pre><p>Inherits <a href="http://qt.nokia.com/doc/4.5/qpushbutton.html">QPushButton</a>.</p>
<ul>
<li><a href="qtcolorpicker-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h3>Properties</h3>
<ul>
<li><div class="fn"></div><b><a href="qtcolorpicker.html#colorDialog-prop">colorDialog</a></b> : bool</li>
</ul>
<ul>
<li><div class="fn"></div>3 properties inherited from <a href="http://qt.nokia.com/doc/4.5/qpushbutton.html#properties">QPushButton</a></li>
<li><div class="fn"></div>11 properties inherited from <a href="http://qt.nokia.com/doc/4.5/qabstractbutton.html#properties">QAbstractButton</a></li>
<li><div class="fn"></div>57 properties inherited from <a href="http://qt.nokia.com/doc/4.5/qwidget.html#properties">QWidget</a></li>
<li><div class="fn"></div>1 property inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"></div><b><a href="qtcolorpicker.html#QtColorPicker">QtColorPicker</a></b> ( QWidget * <i>parent</i> = 0, int <i>cols</i> = -1, bool <i>enableColorDialog</i> = true )</li>
<li><div class="fn"></div><b><a href="qtcolorpicker.html#dtor.QtColorPicker">~QtColorPicker</a></b> ()</li>
<li><div class="fn"></div>QColor <b><a href="qtcolorpicker.html#color">color</a></b> ( int <i>index</i> ) const</li>
<li><div class="fn"></div>bool <b><a href="qtcolorpicker.html#colorDialog-prop">colorDialogEnabled</a></b> () const</li>
<li><div class="fn"></div>QColor <b><a href="qtcolorpicker.html#currentColor">currentColor</a></b> () const</li>
<li><div class="fn"></div>void <b><a href="qtcolorpicker.html#insertColor">insertColor</a></b> ( const QColor & <i>color</i>, const QString & <i>text</i> = QString::null, int <i>index</i> = -1 )</li>
<li><div class="fn"></div>void <b><a href="qtcolorpicker.html#colorDialog-prop">setColorDialogEnabled</a></b> ( bool <i>enabled</i> )</li>
<li><div class="fn"></div>void <b><a href="qtcolorpicker.html#setStandardColors">setStandardColors</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"></div>8 public functions inherited from <a href="http://qt.nokia.com/doc/4.5/qpushbutton.html#public-functions">QPushButton</a></li>
<li><div class="fn"></div>21 public functions inherited from <a href="http://qt.nokia.com/doc/4.5/qabstractbutton.html#public-functions">QAbstractButton</a></li>
<li><div class="fn"></div>207 public functions inherited from <a href="http://qt.nokia.com/doc/4.5/qwidget.html#public-functions">QWidget</a></li>
<li><div class="fn"></div>12 public functions inherited from <a href="http://qt.nokia.com/doc/4.5/qpaintdevice.html#public-functions">QPaintDevice</a></li>
<li><div class="fn"></div>29 public functions inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h3>Public Slots</h3>
<ul>
<li><div class="fn"></div>void <b><a href="qtcolorpicker.html#setCurrentColor">setCurrentColor</a></b> ( const QColor & <i>color</i> )</li>
</ul>
<ul>
<li><div class="fn"></div>1 public slot inherited from <a href="http://qt.nokia.com/doc/4.5/qpushbutton.html#public-slots">QPushButton</a></li>
<li><div class="fn"></div>5 public slots inherited from <a href="http://qt.nokia.com/doc/4.5/qabstractbutton.html#public-slots">QAbstractButton</a></li>
<li><div class="fn"></div>19 public slots inherited from <a href="http://qt.nokia.com/doc/4.5/qwidget.html#public-slots">QWidget</a></li>
<li><div class="fn"></div>1 public slot inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h3>Signals</h3>
<ul>
<li><div class="fn"></div>void <b><a href="qtcolorpicker.html#colorChanged">colorChanged</a></b> ( const QColor & <i>color</i> )</li>
</ul>
<ul>
<li><div class="fn"></div>4 signals inherited from <a href="http://qt.nokia.com/doc/4.5/qabstractbutton.html#signals">QAbstractButton</a></li>
<li><div class="fn"></div>1 signal inherited from <a href="http://qt.nokia.com/doc/4.5/qwidget.html#signals">QWidget</a></li>
<li><div class="fn"></div>1 signal inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"></div>QColor <b><a href="qtcolorpicker.html#getColor">getColor</a></b> ( const QPoint & <i>point</i>, bool <i>allowCustomColors</i> = true )</li>
</ul>
<ul>
<li><div class="fn"></div>4 static public members inherited from <a href="http://qt.nokia.com/doc/4.5/qwidget.html#static-public-members">QWidget</a></li>
<li><div class="fn"></div>4 static public members inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"></div>1 public type inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#public-variables">QObject</a></li>
<li><div class="fn"></div>1 protected function inherited from <a href="http://qt.nokia.com/doc/4.5/qpushbutton.html#protected-functions">QPushButton</a></li>
<li><div class="fn"></div>3 protected functions inherited from <a href="http://qt.nokia.com/doc/4.5/qabstractbutton.html#protected-functions">QAbstractButton</a></li>
<li><div class="fn"></div>37 protected functions inherited from <a href="http://qt.nokia.com/doc/4.5/qwidget.html#protected-functions">QWidget</a></li>
<li><div class="fn"></div>1 protected function inherited from <a href="http://qt.nokia.com/doc/4.5/qpaintdevice.html#protected-functions">QPaintDevice</a></li>
<li><div class="fn"></div>7 protected functions inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#protected-functions">QObject</a></li>
<li><div class="fn"></div>1 protected slot inherited from <a href="http://qt.nokia.com/doc/4.5/qwidget.html#protected-slots">QWidget</a></li>
<li><div class="fn"></div>1 protected type inherited from <a href="http://qt.nokia.com/doc/4.5/qpaintdevice.html#protected-variables">QPaintDevice</a></li>
<li><div class="fn"></div>2 protected variables inherited from <a href="http://qt.nokia.com/doc/4.5/qobject.html#protected-variables">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QtColorPicker class provides a widget for selecting colors from a popup color grid.</p>
<p>Users can invoke the color picker by clicking on it, or by navigating to it and pressing Space. They can use the mouse or arrow keys to navigate between colors on the grid, and select a color by clicking or by pressing Enter or Space. The <a href="qtcolorpicker.html#colorChanged">colorChanged</a>() signal is emitted whenever the color picker's color changes.</p>
<p>The widget also supports negative selection: Users can click and hold the mouse button on the QtColorPicker widget, then move the mouse over the color grid and release the mouse button over the color they wish to select.</p>
<p>The color grid shows a customized selection of colors. An optional ellipsis "..." button (signifying "more") can be added at the bottom of the grid; if the user presses this, a <a href="http://qt.nokia.com/doc/4.5/qcolordialog.html">QColorDialog</a> pops up and lets them choose any color they like. This button is made available by using <a href="qtcolorpicker.html#colorDialog-prop">setColorDialogEnabled</a>().</p>
<p>When a color is selected, the QtColorPicker widget shows the color and its name. If the name cannot be determined, the translatable name "Custom" is used.</p>
<p>The QtColorPicker object is optionally initialized with the number of columns in the color grid. Colors are then added left to right, top to bottom using <a href="qtcolorpicker.html#insertColor">insertColor</a>(). If the number of columns is not set, QtColorPicker calculates the number of columns and rows that will make the grid as square as possible.</p>
<pre> DrawWidget::DrawWidget(QWidget *parent, const char *name)
{
QtColorPicker *picker = new QtColorPicker(this);
picker->insertColor(red, "Red"));
picker->insertColor(QColor("green"), "Green"));
picker->insertColor(QColor(0, 0, 255), "Blue"));
picker->insertColor(white);
connect(colors, SIGNAL(colorChanged(const QColor &)), SLOT(setCurrentColor(const QColor &)));
}</pre>
<p>An alternative to adding colors manually is to initialize the grid with <a href="http://qt.nokia.com/doc/4.5/qcolordialog.html">QColorDialog</a>'s standard colors using <a href="qtcolorpicker.html#setStandardColors">setStandardColors</a>().</p>
<p>QtColorPicker also provides a the static function <a href="qtcolorpicker.html#getColor">getColor</a>(), which pops up the grid of standard colors at any given point.</p>
<p align="center"><img src="images/colorpicker1.png" /></p><p align="center"><img src="images/colorpicker2.png" /></p><p>See also <a href="http://qt.nokia.com/doc/4.5/qcolordialog.html">QColorDialog</a>.</p>
<hr />
<h2>Property Documentation</h2>
<h3 class="fn"><a name="colorDialog-prop"></a>colorDialog : bool</h3>
<p>This property holds whether the ellipsis "..." (more) button is available.</p>
<p>If this property is set to TRUE, the color grid popup will include a "More" button (signified by an ellipsis, "...") which pops up a <a href="http://qt.nokia.com/doc/4.5/qcolordialog.html">QColorDialog</a> when clicked. The user will then be able to select any custom color they like.</p>
<p>Access functions:</p>
<ul>
<li><div class="fn"></div><b>bool colorDialogEnabled () const</b></li>
<li><div class="fn"></div><b>void setColorDialogEnabled ( bool <i>enabled</i> )</b></li>
</ul>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QtColorPicker"></a>QtColorPicker::QtColorPicker ( <a href="http://qt.nokia.com/doc/4.5/qwidget.html">QWidget</a> * <i>parent</i> = 0, int <i>cols</i> = -1, bool <i>enableColorDialog</i> = true )</h3>
<p>Constructs a <a href="qtcolorpicker.html">QtColorPicker</a> widget. The popup will display a grid with <i>cols</i> columns, or if <i>cols</i> is -1, the number of columns will be calculated automatically.</p>
<p>If <i>enableColorDialog</i> is true, the popup will also have a "More" button (signified by an ellipsis "...") that presents a <a href="http://qt.nokia.com/doc/4.5/qcolordialog.html">QColorDialog</a> when clicked.</p>
<p>After constructing a <a href="qtcolorpicker.html">QtColorPicker</a>, call <a href="qtcolorpicker.html#insertColor">insertColor</a>() to add individual colors to the popup grid, or call <a href="qtcolorpicker.html#setStandardColors">setStandardColors</a>() to add all the standard colors in one go.</p>
<p>The <i>parent</i> argument is passed to <a href="http://qt.nokia.com/doc/4.5/qframe.html">QFrame</a>'s constructor.</p>
<p>See also <a href="http://qt.nokia.com/doc/4.5/qframe.html">QFrame</a>.</p>
<h3 class="fn"><a name="dtor.QtColorPicker"></a>QtColorPicker::~QtColorPicker ()</h3>
<p>Destructs the <a href="qtcolorpicker.html">QtColorPicker</a>.</p>
<h3 class="fn"><a name="color"></a><a href="http://qt.nokia.com/doc/4.5/qcolor.html">QColor</a> QtColorPicker::color ( int <i>index</i> ) const</h3>
<p>Returns the color at position <i>index</i>.</p>
<h3 class="fn"><a name="colorChanged"></a>void QtColorPicker::colorChanged ( const <a href="http://qt.nokia.com/doc/4.5/qcolor.html">QColor</a> & <i>color</i> ) <tt> [signal]</tt></h3>
<p>This signal is emitted when the <a href="qtcolorpicker.html">QtColorPicker</a>'s color is changed. <i>color</i> is the new color.</p>
<p>To obtain the color's name, use <a href="http://qt.nokia.com/doc/4.5/qabstractbutton.html#text-prop">text</a>().</p>
<h3 class="fn"><a name="currentColor"></a><a href="http://qt.nokia.com/doc/4.5/qcolor.html">QColor</a> QtColorPicker::currentColor () const</h3>
<p>Returns the currently selected color.</p>
<p>See also <a href="qtcolorpicker.html#setCurrentColor">setCurrentColor</a>() and <a href="http://qt.nokia.com/doc/4.5/qabstractbutton.html#text-prop">text</a>().</p>
<h3 class="fn"><a name="getColor"></a><a href="http://qt.nokia.com/doc/4.5/qcolor.html">QColor</a> QtColorPicker::getColor ( const <a href="http://qt.nokia.com/doc/4.5/qpoint.html">QPoint</a> & <i>point</i>, bool <i>allowCustomColors</i> = true ) <tt> [static]</tt></h3>
<p>Pops up a color grid with Qt default colors at <i>point</i>, using global coordinates. If <i>allowCustomColors</i> is true, there will also be a button on the popup that invokes <a href="http://qt.nokia.com/doc/4.5/qcolordialog.html">QColorDialog</a>.</p>
<p>For example:</p>
<pre> void Drawer::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() & RightButton) {
QColor color = QtColorPicker::getColor(mapToGlobal(e->pos()));
}
}</pre>
<h3 class="fn"><a name="insertColor"></a>void QtColorPicker::insertColor ( const <a href="http://qt.nokia.com/doc/4.5/qcolor.html">QColor</a> & <i>color</i>, const <a href="http://qt.nokia.com/doc/4.5/qstring.html">QString</a> & <i>text</i> = QString::null, int <i>index</i> = -1 )</h3>
<p>Adds the color <i>color</i> with the name <i>text</i> to the color grid, at position <i>index</i>. If index is -1, the color is assigned automatically assigned a position, starting from left to right, top to bottom.</p>
<h3 class="fn"><a name="setCurrentColor"></a>void QtColorPicker::setCurrentColor ( const <a href="http://qt.nokia.com/doc/4.5/qcolor.html">QColor</a> & <i>color</i> ) <tt> [slot]</tt></h3>
<p>Makes <i>color</i> current. If <i>color</i> is not already in the color grid, it is inserted with the text "Custom".</p>
<p>This function emits the <a href="qtcolorpicker.html#colorChanged">colorChanged</a>() signal if the new color is valid, and different from the old one.</p>
<p>See also <a href="qtcolorpicker.html#currentColor">currentColor</a>().</p>
<h3 class="fn"><a name="setStandardColors"></a>void QtColorPicker::setStandardColors ()</h3>
<p>Adds the 17 predefined colors from the Qt namespace.</p>
<p>(The names given to the colors, "Black", "White", "Red", etc., are all translatable.)</p>
<p>See also <a href="qtcolorpicker.html#insertColor">insertColor</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="40%" align="center"><a href="http://qt.nokia.com/doc/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>
|