File: qitemdelegate.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (307 lines) | stat: -rw-r--r-- 36,865 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qitemdelegate.cpp -->
  <title>Qt 4.8: QItemDelegate Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QItemDelegate</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#standard-roles-and-data-types">Standard Roles and Data Types</a></li>
<li class="level2"><a href="#subclassing">Subclassing</a></li>
<li class="level2"><a href="#qstyleditemdelegate-vs-qitemdelegate">QStyledItemDelegate vs. QItemDelegate</a></li>
</ul>
</div>
<h1 class="title">QItemDelegate Class Reference</h1>
<!-- $$$QItemDelegate-brief -->
<p>The QItemDelegate class provides display and editing facilities for data items from a model. <a href="#details">More...</a></p>
<!-- @@@QItemDelegate -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QItemDelegate&gt;</span></pre><p><b>Inherits: </b><a href="qabstractitemdelegate.html">QAbstractItemDelegate</a>.</p>
<p><b>Inherited by: </b><a href="qsqlrelationaldelegate.html">QSqlRelationalDelegate</a>.</p>
<ul>
<li><a href="qitemdelegate-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><a href="qitemdelegate.html#clipping-prop">clipping</a></b> : bool</li>
</ul>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#QItemDelegate">QItemDelegate</a></b> ( QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#dtor.QItemDelegate">~QItemDelegate</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#clipping-prop">hasClipping</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QItemEditorFactory * </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#itemEditorFactory">itemEditorFactory</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#clipping-prop">setClipping</a></b> ( bool <i>clip</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#setItemEditorFactory">setItemEditorFactory</a></b> ( QItemEditorFactory * <i>factory</i> )</td></tr>
</table>
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QWidget * </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#createEditor">createEditor</a></b> ( QWidget * <i>parent</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QModelIndex &amp; <i>index</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#paint">paint</a></b> ( QPainter * <i>painter</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QModelIndex &amp; <i>index</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#setEditorData">setEditorData</a></b> ( QWidget * <i>editor</i>, const QModelIndex &amp; <i>index</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#setModelData">setModelData</a></b> ( QWidget * <i>editor</i>, QAbstractItemModel * <i>model</i>, const QModelIndex &amp; <i>index</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QSize </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#sizeHint">sizeHint</a></b> ( const QStyleOptionViewItem &amp; <i>option</i>, const QModelIndex &amp; <i>index</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#updateEditorGeometry">updateEditorGeometry</a></b> ( QWidget * <i>editor</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QModelIndex &amp; <i>index</i> ) const</td></tr>
</table>
<ul>
<li class="fn">7 public functions inherited from <a href="qabstractitemdelegate.html#public-functions">QAbstractItemDelegate</a></li>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#drawBackground">drawBackground</a></b> ( QPainter * <i>painter</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QModelIndex &amp; <i>index</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#drawCheck">drawCheck</a></b> ( QPainter * <i>painter</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QRect &amp; <i>rect</i>, Qt::CheckState <i>state</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#drawDecoration">drawDecoration</a></b> ( QPainter * <i>painter</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QRect &amp; <i>rect</i>, const QPixmap &amp; <i>pixmap</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#drawDisplay">drawDisplay</a></b> ( QPainter * <i>painter</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QRect &amp; <i>rect</i>, const QString &amp; <i>text</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#drawFocus">drawFocus</a></b> ( QPainter * <i>painter</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QRect &amp; <i>rect</i> ) const</td></tr>
</table>
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#editorEvent">editorEvent</a></b> ( QEvent * <i>event</i>, QAbstractItemModel * <i>model</i>, const QStyleOptionViewItem &amp; <i>option</i>, const QModelIndex &amp; <i>index</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qitemdelegate.html#eventFilter">eventFilter</a></b> ( QObject * <i>editor</i>, QEvent * <i>event</i> )</td></tr>
</table>
<ul>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 public slot inherited from <a href="qabstractitemdelegate.html#public-slots">QAbstractItemDelegate</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">3 signals inherited from <a href="qabstractitemdelegate.html#signals">QAbstractItemDelegate</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QItemDelegate-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QItemDelegate class provides display and editing facilities for data items from a model.</p>
<p>QItemDelegate can be used to provide custom display features and editor widgets for item views based on <a href="qabstractitemview.html">QAbstractItemView</a> subclasses. Using a delegate for this purpose allows the display and editing mechanisms to be customized and developed independently from the model and view.</p>
<p>The QItemDelegate class is one of the <a href="model-view.html">Model/View Classes</a> and is part of Qt's <a href="model-view-programming.html">model/view framework</a>. Note that <a href="qstyleditemdelegate.html">QStyledItemDelegate</a> has taken over the job of drawing Qt's item views. We recommend the use of <a href="qstyleditemdelegate.html">QStyledItemDelegate</a> when creating new delegates.</p>
<p>When displaying items from a custom model in a standard view, it is often sufficient to simply ensure that the model returns appropriate data for each of the <a href="qt.html#ItemDataRole-enum">roles</a> that determine the appearance of items in views. The default delegate used by Qt's standard views uses this role information to display items in most of the common forms expected by users. However, it is sometimes necessary to have even more control over the appearance of items than the default delegate can provide.</p>
<p>This class provides default implementations of the functions for painting item data in a view and editing data from item models. Default implementations of the <a href="qitemdelegate.html#paint">paint</a>() and <a href="qitemdelegate.html#sizeHint">sizeHint</a>() virtual functions, defined in <a href="qabstractitemdelegate.html">QAbstractItemDelegate</a>, are provided to ensure that the delegate implements the correct basic behavior expected by views. You can reimplement these functions in subclasses to customize the appearance of items.</p>
<p>When editing data in an item view, QItemDelegate provides an editor widget, which is a widget that is placed on top of the view while editing takes place. Editors are created with a <a href="qitemeditorfactory.html">QItemEditorFactory</a>; a default static instance provided by <a href="qitemeditorfactory.html">QItemEditorFactory</a> is installed on all item delegates. You can set a custom factory using <a href="qitemdelegate.html#setItemEditorFactory">setItemEditorFactory</a>() or set a new default factory with <a href="qitemeditorfactory.html#setDefaultFactory">QItemEditorFactory::setDefaultFactory</a>(). It is the data stored in the item model with the <a href="qt.html#ItemDataRole-enum">Qt::EditRole</a> that is edited.</p>
<p>Only the standard editing functions for widget-based delegates are reimplemented here:</p>
<ul>
<li><a href="qitemdelegate.html#createEditor">createEditor</a>() returns the widget used to change data from the model and can be reimplemented to customize editing behavior.</li>
<li><a href="qitemdelegate.html#setEditorData">setEditorData</a>() provides the widget with data to manipulate.</li>
<li><a href="qitemdelegate.html#updateEditorGeometry">updateEditorGeometry</a>() ensures that the editor is displayed correctly with respect to the item view.</li>
<li><a href="qitemdelegate.html#setModelData">setModelData</a>() returns updated data to the model.</li>
</ul>
<p>The <a href="qabstractitemdelegate.html#closeEditor">closeEditor</a>() signal indicates that the user has completed editing the data, and that the editor widget can be destroyed.</p>
<a name="standard-roles-and-data-types"></a>
<h3>Standard Roles and Data Types</h3>
<p>The default delegate used by the standard views supplied with Qt associates each standard role (defined by <a href="qt.html#ItemDataRole-enum">Qt::ItemDataRole</a>) with certain data types. Models that return data in these types can influence the appearance of the delegate as described in the following table.</p>
<table class="generic">
<thead><tr class="qt-style"><th >Role</th><th >Accepted Types</th></tr></thead>
<tr valign="top" class="odd"><td ><a href="qt.html#ItemDataRole-enum">Qt::BackgroundRole</a></td><td ><a href="qbrush.html">QBrush</a></td></tr>
<tr valign="top" class="even"><td ><a href="qt.html#ItemDataRole-enum">Qt::BackgroundColorRole</a></td><td ><a href="qcolor.html">QColor</a> (obsolete; use <a href="qt.html#ItemDataRole-enum">Qt::BackgroundRole</a> instead)</td></tr>
<tr valign="top" class="odd"><td ><a href="qt.html#ItemDataRole-enum">Qt::CheckStateRole</a></td><td ><a href="qt.html#CheckState-enum">Qt::CheckState</a></td></tr>
<tr valign="top" class="even"><td ><a href="qt.html#ItemDataRole-enum">Qt::DecorationRole</a></td><td ><a href="qicon.html">QIcon</a>, <a href="qpixmap.html">QPixmap</a> and <a href="qcolor.html">QColor</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qt.html#ItemDataRole-enum">Qt::DisplayRole</a></td><td ><a href="qstring.html">QString</a> and types with a string representation</td></tr>
<tr valign="top" class="even"><td ><a href="qt.html#ItemDataRole-enum">Qt::EditRole</a></td><td >See <a href="qitemeditorfactory.html">QItemEditorFactory</a> for details</td></tr>
<tr valign="top" class="odd"><td ><a href="qt.html#ItemDataRole-enum">Qt::FontRole</a></td><td ><a href="qfont.html">QFont</a></td></tr>
<tr valign="top" class="even"><td ><a href="qt.html#ItemDataRole-enum">Qt::SizeHintRole</a></td><td ><a href="qsize.html">QSize</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qt.html#ItemDataRole-enum">Qt::TextAlignmentRole</a></td><td ><a href="qt.html#AlignmentFlag-enum">Qt::Alignment</a></td></tr>
<tr valign="top" class="even"><td ><a href="qt.html#ItemDataRole-enum">Qt::ForegroundRole</a></td><td ><a href="qbrush.html">QBrush</a></td></tr>
<tr valign="top" class="odd"><td ><a href="qt.html#ItemDataRole-enum">Qt::TextColorRole</a></td><td ><a href="qcolor.html">QColor</a> (obsolete; use <a href="qt.html#ItemDataRole-enum">Qt::ForegroundRole</a> instead)</td></tr>
</table>
<p>If the default delegate does not allow the level of customization that you need, either for display purposes or for editing data, it is possible to subclass QItemDelegate to implement the desired behavior.</p>
<a name="subclassing"></a>
<h3>Subclassing</h3>
<p>When subclassing QItemDelegate to create a delegate that displays items using a custom renderer, it is important to ensure that the delegate can render items suitably for all the required states; e.g&#x2e; selected, disabled, checked. The documentation for the <a href="qitemdelegate.html#paint">paint</a>() function contains some hints to show how this can be achieved.</p>
<p>You can provide custom editors by using a <a href="qitemeditorfactory.html">QItemEditorFactory</a>. The <a href="itemviews-coloreditorfactory.html">Color Editor Factory Example</a> shows how a custom editor can be made available to delegates with the default item editor factory. This way, there is no need to subclass QItemDelegate. An alternative is to reimplement <a href="qitemdelegate.html#createEditor">createEditor</a>(), <a href="qitemdelegate.html#setEditorData">setEditorData</a>(), <a href="qitemdelegate.html#setModelData">setModelData</a>(), and <a href="qitemdelegate.html#updateEditorGeometry">updateEditorGeometry</a>(). This process is described in the <a href="itemviews-spinboxdelegate.html">Spin Box Delegate Example</a>.</p>
<a name="qstyleditemdelegate-vs-qitemdelegate"></a>
<h3>QStyledItemDelegate vs. QItemDelegate</h3>
<p>Since Qt 4.4, there are two delegate classes: QItemDelegate and <a href="qstyleditemdelegate.html">QStyledItemDelegate</a>. However, the default delegate is <a href="qstyleditemdelegate.html">QStyledItemDelegate</a>. These two classes are independent alternatives to painting and providing editors for items in views. The difference between them is that <a href="qstyleditemdelegate.html">QStyledItemDelegate</a> uses the current style to paint its items. We therefore recommend using <a href="qstyleditemdelegate.html">QStyledItemDelegate</a> as the base class when implementing custom delegates or when working with Qt style sheets. The code required for either class should be equal unless the custom delegate needs to use the style for drawing.</p>
</div>
<p><b>See also </b><a href="model-view-programming.html#delegate-classes">Delegate Classes</a>, <a href="qstyleditemdelegate.html">QStyledItemDelegate</a>, <a href="qabstractitemdelegate.html">QAbstractItemDelegate</a>, <a href="itemviews-spinboxdelegate.html">Spin Box Delegate Example</a>, <a href="tools-settingseditor.html">Settings Editor Example</a>, and <a href="widgets-icons.html">Icons Example</a>.</p>
<!-- @@@QItemDelegate -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$clipping-prop$$$hasClipping$$$setClippingbool -->
<h3 class="fn"><a name="clipping-prop"></a><span class="name">clipping</span> : <span class="type">bool</span></h3>
<p>This property holds if the delegate should clip the paint events.</p>
<p>This property will set the paint clip to the size of the item. The default value is on. It is useful for cases such as when images are larger than the size of the item.</p>
<p>This property was introduced in Qt 4.2.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>hasClipping</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setClipping</b></span> ( bool <i>clip</i> )</td></tr>
</table>
<!-- @@@clipping -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QItemDelegate[overload1]$$$QItemDelegateQObject* -->
<h3 class="fn"><a name="QItemDelegate"></a>QItemDelegate::<span class="name">QItemDelegate</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs an item delegate with the given <i>parent</i>.</p>
<!-- @@@QItemDelegate -->
<!-- $$$~QItemDelegate[overload1]$$$~QItemDelegate -->
<h3 class="fn"><a name="dtor.QItemDelegate"></a>QItemDelegate::<span class="name">~QItemDelegate</span> ()</h3>
<p>Destroys the item delegate.</p>
<!-- @@@~QItemDelegate -->
<!-- $$$createEditor[overload1]$$$createEditorQWidget*constQStyleOptionViewItem&constQModelIndex& -->
<h3 class="fn"><a name="createEditor"></a><span class="type"><a href="qwidget.html">QWidget</a></span> * QItemDelegate::<span class="name">createEditor</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>parent</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> ) const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qabstractitemdelegate.html#createEditor">QAbstractItemDelegate::createEditor</a>().</p>
<p>Returns the widget used to edit the item specified by <i>index</i> for editing. The <i>parent</i> widget and style <i>option</i> are used to control how the editor widget appears.</p>
<p><b>See also </b><a href="qabstractitemdelegate.html#createEditor">QAbstractItemDelegate::createEditor</a>().</p>
<!-- @@@createEditor -->
<!-- $$$drawBackground[overload1]$$$drawBackgroundQPainter*constQStyleOptionViewItem&constQModelIndex& -->
<h3 class="fn"><a name="drawBackground"></a><span class="type">void</span> QItemDelegate::<span class="name">drawBackground</span> ( <span class="type"><a href="qpainter.html">QPainter</a></span> * <i>painter</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> ) const<tt> [protected]</tt></h3>
<p>Renders the item background for the given <i>index</i>, using the given <i>painter</i> and style <i>option</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@drawBackground -->
<!-- $$$drawCheck[overload1]$$$drawCheckQPainter*constQStyleOptionViewItem&constQRect&Qt::CheckState -->
<h3 class="fn"><a name="drawCheck"></a><span class="type">void</span> QItemDelegate::<span class="name">drawCheck</span> ( <span class="type"><a href="qpainter.html">QPainter</a></span> * <i>painter</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qrect.html">QRect</a></span> &amp; <i>rect</i>, <span class="type"><a href="qt.html#CheckState-enum">Qt::CheckState</a></span> <i>state</i> ) const<tt> [virtual protected]</tt></h3>
<p>Renders a check indicator within the rectangle specified by <i>rect</i>, using the given <i>painter</i> and style <i>option</i>, using the given <i>state</i>.</p>
<!-- @@@drawCheck -->
<!-- $$$drawDecoration[overload1]$$$drawDecorationQPainter*constQStyleOptionViewItem&constQRect&constQPixmap& -->
<h3 class="fn"><a name="drawDecoration"></a><span class="type">void</span> QItemDelegate::<span class="name">drawDecoration</span> ( <span class="type"><a href="qpainter.html">QPainter</a></span> * <i>painter</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qrect.html">QRect</a></span> &amp; <i>rect</i>, const <span class="type"><a href="qpixmap.html">QPixmap</a></span> &amp; <i>pixmap</i> ) const<tt> [virtual protected]</tt></h3>
<p>Renders the decoration <i>pixmap</i> within the rectangle specified by <i>rect</i> using the given <i>painter</i> and style <i>option</i>.</p>
<!-- @@@drawDecoration -->
<!-- $$$drawDisplay[overload1]$$$drawDisplayQPainter*constQStyleOptionViewItem&constQRect&constQString& -->
<h3 class="fn"><a name="drawDisplay"></a><span class="type">void</span> QItemDelegate::<span class="name">drawDisplay</span> ( <span class="type"><a href="qpainter.html">QPainter</a></span> * <i>painter</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qrect.html">QRect</a></span> &amp; <i>rect</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>text</i> ) const<tt> [virtual protected]</tt></h3>
<p>Renders the item view <i>text</i> within the rectangle specified by <i>rect</i> using the given <i>painter</i> and style <i>option</i>.</p>
<!-- @@@drawDisplay -->
<!-- $$$drawFocus[overload1]$$$drawFocusQPainter*constQStyleOptionViewItem&constQRect& -->
<h3 class="fn"><a name="drawFocus"></a><span class="type">void</span> QItemDelegate::<span class="name">drawFocus</span> ( <span class="type"><a href="qpainter.html">QPainter</a></span> * <i>painter</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qrect.html">QRect</a></span> &amp; <i>rect</i> ) const<tt> [virtual protected]</tt></h3>
<p>Renders the region within the rectangle specified by <i>rect</i>, indicating that it has the focus, using the given <i>painter</i> and style <i>option</i>.</p>
<!-- @@@drawFocus -->
<!-- $$$editorEvent[overload1]$$$editorEventQEvent*QAbstractItemModel*constQStyleOptionViewItem&constQModelIndex& -->
<h3 class="fn"><a name="editorEvent"></a><span class="type">bool</span> QItemDelegate::<span class="name">editorEvent</span> ( <span class="type"><a href="qevent.html">QEvent</a></span> * <i>event</i>, <span class="type"><a href="qabstractitemmodel.html">QAbstractItemModel</a></span> * <i>model</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qabstractitemdelegate.html#editorEvent">QAbstractItemDelegate::editorEvent</a>().</p>
<!-- @@@editorEvent -->
<!-- $$$eventFilter[overload1]$$$eventFilterQObject*QEvent* -->
<h3 class="fn"><a name="eventFilter"></a><span class="type">bool</span> QItemDelegate::<span class="name">eventFilter</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>editor</i>, <span class="type"><a href="qevent.html">QEvent</a></span> * <i>event</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qobject.html#eventFilter">QObject::eventFilter</a>().</p>
<p>Returns true if the given <i>editor</i> is a valid <a href="qwidget.html">QWidget</a> and the given <i>event</i> is handled; otherwise returns false. The following key press events are handled by default:</p>
<ul>
<li><b>Tab</b></li>
<li><b>Backtab</b></li>
<li><b>Enter</b></li>
<li><b>Return</b></li>
<li><b>Esc</b></li>
</ul>
<p>In the case of <b>Tab</b>, <b>Backtab</b>, <b>Enter</b> and <b>Return</b> key press events, the <i>editor</i>'s data is comitted to the model and the editor is closed. If the <i>event</i> is a <b>Tab</b> key press the view will open an editor on the next item in the view. Likewise, if the <i>event</i> is a <b>Backtab</b> key press the view will open an editor on the <i>previous</i> item in the view.</p>
<p>If the event is a <b>Esc</b> key press event, the <i>editor</i> is closed <i>without</i> committing its data.</p>
<p><b>See also </b><a href="qabstractitemdelegate.html#commitData">commitData</a>() and <a href="qabstractitemdelegate.html#closeEditor">closeEditor</a>().</p>
<!-- @@@eventFilter -->
<!-- $$$itemEditorFactory[overload1]$$$itemEditorFactory -->
<h3 class="fn"><a name="itemEditorFactory"></a><span class="type"><a href="qitemeditorfactory.html">QItemEditorFactory</a></span> * QItemDelegate::<span class="name">itemEditorFactory</span> () const</h3>
<p>Returns the editor factory used by the item delegate. If no editor factory is set, the function will return null.</p>
<p><b>See also </b><a href="qitemdelegate.html#setItemEditorFactory">setItemEditorFactory</a>().</p>
<!-- @@@itemEditorFactory -->
<!-- $$$paint[overload1]$$$paintQPainter*constQStyleOptionViewItem&constQModelIndex& -->
<h3 class="fn"><a name="paint"></a><span class="type">void</span> QItemDelegate::<span class="name">paint</span> ( <span class="type"><a href="qpainter.html">QPainter</a></span> * <i>painter</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> ) const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qabstractitemdelegate.html#paint">QAbstractItemDelegate::paint</a>().</p>
<p>Renders the delegate using the given <i>painter</i> and style <i>option</i> for the item specified by <i>index</i>.</p>
<p>When reimplementing this function in a subclass, you should update the area held by the option's <a href="qstyleoption.html#rect-var">rect</a> variable, using the option's <a href="qstyleoption.html#state-var">state</a> variable to determine the state of the item to be displayed, and adjust the way it is painted accordingly.</p>
<p>For example, a selected item may need to be displayed differently to unselected items, as shown in the following code:</p>
<pre class="cpp">     <span class="keyword">if</span> (option<span class="operator">.</span>state <span class="operator">&amp;</span> <span class="type"><a href="qstyle.html">QStyle</a></span><span class="operator">::</span>State_Selected)
         painter<span class="operator">-</span><span class="operator">&gt;</span>fillRect(option<span class="operator">.</span>rect<span class="operator">,</span> option<span class="operator">.</span>palette<span class="operator">.</span>highlight());

     <span class="type">int</span> size <span class="operator">=</span> <a href="qtglobal.html#qMin">qMin</a>(option<span class="operator">.</span>rect<span class="operator">.</span>width()<span class="operator">,</span> option<span class="operator">.</span>rect<span class="operator">.</span>height());
     <span class="type">int</span> brightness <span class="operator">=</span> index<span class="operator">.</span>model()<span class="operator">-</span><span class="operator">&gt;</span>data(index<span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">::</span>DisplayRole)<span class="operator">.</span>toInt();
     <span class="type">double</span> radius <span class="operator">=</span> (size<span class="operator">/</span><span class="number">2.0</span>) <span class="operator">-</span> (brightness<span class="operator">/</span><span class="number">255.0</span> <span class="operator">*</span> size<span class="operator">/</span><span class="number">2.0</span>);
     <span class="keyword">if</span> (radius <span class="operator">=</span><span class="operator">=</span> <span class="number">0.0</span>)
         <span class="keyword">return</span>;

     painter<span class="operator">-</span><span class="operator">&gt;</span>save();
     painter<span class="operator">-</span><span class="operator">&gt;</span>setRenderHint(<span class="type"><a href="qpainter.html">QPainter</a></span><span class="operator">::</span>Antialiasing<span class="operator">,</span> <span class="keyword">true</span>);
     painter<span class="operator">-</span><span class="operator">&gt;</span>setPen(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">::</span>NoPen);
     <span class="keyword">if</span> (option<span class="operator">.</span>state <span class="operator">&amp;</span> <span class="type"><a href="qstyle.html">QStyle</a></span><span class="operator">::</span>State_Selected)
         painter<span class="operator">-</span><span class="operator">&gt;</span>setBrush(option<span class="operator">.</span>palette<span class="operator">.</span>highlightedText());
     <span class="keyword">else</span>
     ...</pre>
<p>After painting, you should ensure that the painter is returned to its the state it was supplied in when this function was called. For example, it may be useful to call <a href="qpainter.html#save">QPainter::save</a>() before painting and <a href="qpainter.html#restore">QPainter::restore</a>() afterwards.</p>
<p><b>See also </b><a href="qstyle.html#StateFlag-enum">QStyle::State</a>.</p>
<!-- @@@paint -->
<!-- $$$setEditorData[overload1]$$$setEditorDataQWidget*constQModelIndex& -->
<h3 class="fn"><a name="setEditorData"></a><span class="type">void</span> QItemDelegate::<span class="name">setEditorData</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>editor</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> ) const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qabstractitemdelegate.html#setEditorData">QAbstractItemDelegate::setEditorData</a>().</p>
<p>Sets the data to be displayed and edited by the <i>editor</i> from the data model item specified by the model <i>index</i>.</p>
<p>The default implementation stores the data in the <i>editor</i> widget's <a href="properties.html#qt-s-property-system">user property</a>.</p>
<p><b>See also </b><a href="qmetaproperty.html#isUser">QMetaProperty::isUser</a>().</p>
<!-- @@@setEditorData -->
<!-- $$$setItemEditorFactory[overload1]$$$setItemEditorFactoryQItemEditorFactory* -->
<h3 class="fn"><a name="setItemEditorFactory"></a><span class="type">void</span> QItemDelegate::<span class="name">setItemEditorFactory</span> ( <span class="type"><a href="qitemeditorfactory.html">QItemEditorFactory</a></span> * <i>factory</i> )</h3>
<p>Sets the editor factory to be used by the item delegate to be the <i>factory</i> specified. If no editor factory is set, the item delegate will use the default editor factory.</p>
<p><b>See also </b><a href="qitemdelegate.html#itemEditorFactory">itemEditorFactory</a>().</p>
<!-- @@@setItemEditorFactory -->
<!-- $$$setModelData[overload1]$$$setModelDataQWidget*QAbstractItemModel*constQModelIndex& -->
<h3 class="fn"><a name="setModelData"></a><span class="type">void</span> QItemDelegate::<span class="name">setModelData</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>editor</i>, <span class="type"><a href="qabstractitemmodel.html">QAbstractItemModel</a></span> * <i>model</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> ) const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qabstractitemdelegate.html#setModelData">QAbstractItemDelegate::setModelData</a>().</p>
<p>Gets data from the <i>editor</i> widget and stores it in the specified <i>model</i> at the item <i>index</i>.</p>
<p>The default implementation gets the value to be stored in the data model from the <i>editor</i> widget's <a href="properties.html#qt-s-property-system">user property</a>.</p>
<p><b>See also </b><a href="qmetaproperty.html#isUser">QMetaProperty::isUser</a>().</p>
<!-- @@@setModelData -->
<!-- $$$sizeHint[overload1]$$$sizeHintconstQStyleOptionViewItem&constQModelIndex& -->
<h3 class="fn"><a name="sizeHint"></a><span class="type"><a href="qsize.html">QSize</a></span> QItemDelegate::<span class="name">sizeHint</span> ( const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> ) const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qabstractitemdelegate.html#sizeHint">QAbstractItemDelegate::sizeHint</a>().</p>
<p>Returns the size needed by the delegate to display the item specified by <i>index</i>, taking into account the style information provided by <i>option</i>.</p>
<p>When reimplementing this function, note that in case of text items, <a href="qitemdelegate.html">QItemDelegate</a> adds a margin (i.e&#x2e; 2 * <a href="qstyle.html#PixelMetric-enum">QStyle::PM_FocusFrameHMargin</a>) to the length of the text.</p>
<!-- @@@sizeHint -->
<!-- $$$updateEditorGeometry[overload1]$$$updateEditorGeometryQWidget*constQStyleOptionViewItem&constQModelIndex& -->
<h3 class="fn"><a name="updateEditorGeometry"></a><span class="type">void</span> QItemDelegate::<span class="name">updateEditorGeometry</span> ( <span class="type"><a href="qwidget.html">QWidget</a></span> * <i>editor</i>, const <span class="type"><a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a></span> &amp; <i>option</i>, const <span class="type"><a href="qmodelindex.html">QModelIndex</a></span> &amp; <i>index</i> ) const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qabstractitemdelegate.html#updateEditorGeometry">QAbstractItemDelegate::updateEditorGeometry</a>().</p>
<p>Updates the <i>editor</i> for the item specified by <i>index</i> according to the style <i>option</i> given.</p>
<!-- @@@updateEditorGeometry -->
</div>
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>