1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
3
<html><head><title>QItemSelectionModel Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
4
a:link { color: #004faf; text-decoration: none }
5
a:visited { color: #672967; text-decoration: none }
6
td.postheader { font-family: sans-serif }
7
tr.address { font-family: sans-serif }
8
body { background: #ffffff; color: black; }
9
</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">QItemSelectionModel Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QItemSelectionModel class keeps track of a view's selected
10
items. <a href="#details">More...</a></p>
12
<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qitemselectionmodel.html#SelectionFlag-enum">SelectionFlag</a></b> { NoUpdate, Clear, Select, Deselect, ..., ClearAndSelect }</li><li><div class="fn" />class <b><a href="qitemselectionmodel-selectionflags.html">SelectionFlags</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qitemselectionmodel.html#QItemSelectionModel">__init__</a></b> (<i>self</i>, QAbstractItemModel <i>model</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#QItemSelectionModel-2">__init__</a></b> (<i>self</i>, QAbstractItemModel <i>model</i>, QObject <i>parent</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#clearSelection">clearSelection</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qitemselectionmodel.html#columnIntersectsSelection">columnIntersectsSelection</a></b> (<i>self</i>, int <i>column</i>, QModelIndex <i>parent</i>)</li><li><div class="fn" />QModelIndex <b><a href="qitemselectionmodel.html#currentIndex">currentIndex</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#emitSelectionChanged">emitSelectionChanged</a></b> (<i>self</i>, QItemSelection <i>newSelection</i>, QItemSelection <i>oldSelection</i>)</li><li><div class="fn" />bool <b><a href="qitemselectionmodel.html#hasSelection">hasSelection</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qitemselectionmodel.html#isColumnSelected">isColumnSelected</a></b> (<i>self</i>, int <i>column</i>, QModelIndex <i>parent</i>)</li><li><div class="fn" />bool <b><a href="qitemselectionmodel.html#isRowSelected">isRowSelected</a></b> (<i>self</i>, int <i>row</i>, QModelIndex <i>parent</i>)</li><li><div class="fn" />bool <b><a href="qitemselectionmodel.html#isSelected">isSelected</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />QAbstractItemModel <b><a href="qitemselectionmodel.html#model">model</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#reset">reset</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qitemselectionmodel.html#rowIntersectsSelection">rowIntersectsSelection</a></b> (<i>self</i>, int <i>row</i>, QModelIndex <i>parent</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#select">select</a></b> (<i>self</i>, QModelIndex <i>index</i>, SelectionFlags <i>command</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#select-2">select</a></b> (<i>self</i>, QItemSelection <i>selection</i>, SelectionFlags <i>command</i>)</li><li><div class="fn" />list-of-QModelIndex <b><a href="qitemselectionmodel.html#selectedColumns">selectedColumns</a></b> (<i>self</i>, int <i>row</i> = 0)</li><li><div class="fn" />list-of-QModelIndex <b><a href="qitemselectionmodel.html#selectedIndexes">selectedIndexes</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QModelIndex <b><a href="qitemselectionmodel.html#selectedRows">selectedRows</a></b> (<i>self</i>, int <i>column</i> = 0)</li><li><div class="fn" />QItemSelection <b><a href="qitemselectionmodel.html#selection">selection</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qitemselectionmodel.html#setCurrentIndex">setCurrentIndex</a></b> (<i>self</i>, QModelIndex <i>index</i>, SelectionFlags <i>command</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qitemselectionmodel.html#currentChanged">currentChanged</a></b> (const QModelIndex&,const QModelIndex&)</li><li><div class="fn" />void <b><a href="qitemselectionmodel.html#currentColumnChanged">currentColumnChanged</a></b> (const QModelIndex&,const QModelIndex&)</li><li><div class="fn" />void <b><a href="qitemselectionmodel.html#currentRowChanged">currentRowChanged</a></b> (const QModelIndex&,const QModelIndex&)</li><li><div class="fn" />void <b><a href="qitemselectionmodel.html#selectionChanged">selectionChanged</a></b> (const QItemSelection&,const QItemSelection&)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QItemSelectionModel class keeps track of a view's selected
14
<p>A QItemSelectionModel keeps track of the selected items in a
15
view, or in several views onto the same model. It also keeps track
16
of the currently selected item in a view.</p>
17
<p>The QItemSelectionModel class is one of the <a href="model-view.html">Model/View Classes</a> and is part of Qt's
18
<a href="model-view-programming.html">model/view framework</a>.</p>
19
<p>The selected items are stored using ranges. Whenever you want to
20
modify the selected items use <a href="qitemselectionmodel.html#select">select</a>() and provide either a
21
<a href="qitemselection.html">QItemSelection</a>, or a <a href="qmodelindex.html">QModelIndex</a> and a <a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.SelectionFlag</a>.</p>
22
<p>The QItemSelectionModel takes a two layer approach to selection
23
management, dealing with both selected items that have been
24
committed and items that are part of the current selection. The
25
current selected items are part of the current interactive
26
selection (for example with rubber-band selection or keyboard-shift
28
<p>To update the currently selected items, use the bitwise OR of
29
<a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.Current</a>
30
and any of the other <a href="qitemselectionmodel.html#SelectionFlag-enum">SelectionFlags</a>.
31
If you omit the <a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.Current</a>
32
command, a new current selection will be created, and the previous
33
one added to the whole selection. All functions operate on both
34
layers; for example, selectedItems() will return items from both
36
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="SelectionFlag-enum" />QItemSelectionModel.SelectionFlag</h3><p>This enum describes the way the selection model will be
38
<table class="valuelist">
39
<tr class="odd" valign="top">
40
<th class="tblConst">Constant</th>
41
<th class="tblval">Value</th>
42
<th class="tbldscr">Description</th>
45
<td class="topAlign"><tt>QItemSelectionModel.NoUpdate</tt></td>
46
<td class="topAlign"><tt>0x0000</tt></td>
47
<td class="topAlign">No selection will be made.</td>
50
<td class="topAlign"><tt>QItemSelectionModel.Clear</tt></td>
51
<td class="topAlign"><tt>0x0001</tt></td>
52
<td class="topAlign">The complete selection will be cleared.</td>
55
<td class="topAlign"><tt>QItemSelectionModel.Select</tt></td>
56
<td class="topAlign"><tt>0x0002</tt></td>
57
<td class="topAlign">All specified indexes will be selected.</td>
60
<td class="topAlign"><tt>QItemSelectionModel.Deselect</tt></td>
61
<td class="topAlign"><tt>0x0004</tt></td>
62
<td class="topAlign">All specified indexes will be deselected.</td>
65
<td class="topAlign"><tt>QItemSelectionModel.Toggle</tt></td>
66
<td class="topAlign"><tt>0x0008</tt></td>
67
<td class="topAlign">All specified indexes will be selected or
68
deselected depending on their current state.</td>
71
<td class="topAlign"><tt>QItemSelectionModel.Current</tt></td>
72
<td class="topAlign"><tt>0x0010</tt></td>
73
<td class="topAlign">The current selection will be updated.</td>
76
<td class="topAlign"><tt>QItemSelectionModel.Rows</tt></td>
77
<td class="topAlign"><tt>0x0020</tt></td>
78
<td class="topAlign">All indexes will be expanded to span
82
<td class="topAlign"><tt>QItemSelectionModel.Columns</tt></td>
83
<td class="topAlign"><tt>0x0040</tt></td>
84
<td class="topAlign">All indexes will be expanded to span
89
<tt>QItemSelectionModel.SelectCurrent</tt></td>
90
<td class="topAlign"><tt>Select | Current</tt></td>
91
<td class="topAlign">A combination of Select and Current, provided
96
<tt>QItemSelectionModel.ToggleCurrent</tt></td>
97
<td class="topAlign"><tt>Toggle | Current</tt></td>
98
<td class="topAlign">A combination of Toggle and Current, provided
102
<td class="topAlign">
103
<tt>QItemSelectionModel.ClearAndSelect</tt></td>
104
<td class="topAlign"><tt>Clear | Select</tt></td>
105
<td class="topAlign">A combination of Clear and Select, provided
106
for convenience.</td>
109
<p>The SelectionFlags type is a typedef for <a href="qflags.html">QFlags</a><SelectionFlag>. It stores an OR
110
combination of SelectionFlag values.</p>
111
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QItemSelectionModel" />QItemSelectionModel.__init__ (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a> <i>model</i>)</h3><p>Constructs a selection model that operates on the specified item
115
<h3 class="fn"><a name="QItemSelectionModel-2" />QItemSelectionModel.__init__ (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a> <i>model</i>, <a href="qobject.html">QObject</a> <i>parent</i>)</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 selection model that operates on the specified item
116
<i>model</i> with <i>parent</i>.</p>
119
<h3 class="fn"><a name="clear" />QItemSelectionModel.clear (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void clear()</tt>.</p><p>Clears the selection model. Emits <a href="qitemselectionmodel.html#selectionChanged">selectionChanged</a>()
120
and <a href="qitemselectionmodel.html#currentChanged">currentChanged</a>().</p>
123
<h3 class="fn"><a name="clearSelection" />QItemSelectionModel.clearSelection (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void clearSelection()</tt>.</p><p>Clears the selection in the selection model. Emits <a href="qitemselectionmodel.html#selectionChanged">selectionChanged</a>().</p>
124
<p>This function was introduced in Qt 4.2.</p>
127
<h3 class="fn"><a name="columnIntersectsSelection" />bool QItemSelectionModel.columnIntersectsSelection (<i>self</i>, int <i>column</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>)</h3><p>Returns true if there are any items selected in the
128
<i>column</i> with the given <i>parent</i>.</p>
131
<h3 class="fn"><a name="currentIndex" /><a href="qmodelindex.html">QModelIndex</a> QItemSelectionModel.currentIndex (<i>self</i>)</h3><p>Returns the model item index for the current item, or an invalid
132
index if there is no current item.</p>
133
<p><b>See also</b> <a href="qitemselectionmodel.html#setCurrentIndex">setCurrentIndex</a>().</p>
136
<h3 class="fn"><a name="emitSelectionChanged" />QItemSelectionModel.emitSelectionChanged (<i>self</i>, <a href="qitemselection.html">QItemSelection</a> <i>newSelection</i>, <a href="qitemselection.html">QItemSelection</a> <i>oldSelection</i>)</h3><p>Compares the two selections <i>newSelection</i> and
137
<i>oldSelection</i> and emits <a href="qitemselectionmodel.html#selectionChanged">selectionChanged</a>()
138
with the deselected and selected items.</p>
141
<h3 class="fn"><a name="hasSelection" />bool QItemSelectionModel.hasSelection (<i>self</i>)</h3><p>Returns true if the selection model contains any selection
142
ranges; otherwise returns false.</p>
143
<p>This function was introduced in Qt 4.2.</p>
146
<h3 class="fn"><a name="isColumnSelected" />bool QItemSelectionModel.isColumnSelected (<i>self</i>, int <i>column</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>)</h3><p>Returns true if all items are selected in the <i>column</i> with
147
the given <i>parent</i>.</p>
148
<p>Note that this function is usually faster than calling <a href="qitemselectionmodel.html#isSelected">isSelected</a>() on all items
149
in the same column and that unselectable items are ignored.</p>
152
<h3 class="fn"><a name="isRowSelected" />bool QItemSelectionModel.isRowSelected (<i>self</i>, int <i>row</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>)</h3><p>Returns true if all items are selected in the <i>row</i> with
153
the given <i>parent</i>.</p>
154
<p>Note that this function is usually faster than calling <a href="qitemselectionmodel.html#isSelected">isSelected</a>() on all items
155
in the same row and that unselectable items are ignored.</p>
158
<h3 class="fn"><a name="isSelected" />bool QItemSelectionModel.isSelected (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns true if the given model item <i>index</i> is
162
<h3 class="fn"><a name="model" /><a href="qabstractitemmodel.html">QAbstractItemModel</a> QItemSelectionModel.model (<i>self</i>)</h3><p>Returns the item model operated on by the selection model.</p>
165
<h3 class="fn"><a name="reset" />QItemSelectionModel.reset (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void reset()</tt>.</p><p>Clears the selection model. Does not emit any signals.</p>
168
<h3 class="fn"><a name="rowIntersectsSelection" />bool QItemSelectionModel.rowIntersectsSelection (<i>self</i>, int <i>row</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>)</h3><p>Returns true if there are any items selected in the <i>row</i>
169
with the given <i>parent</i>.</p>
172
<h3 class="fn"><a name="select" />QItemSelectionModel.select (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>, <a href="qitemselectionmodel-selectionflags.html">SelectionFlags</a> <i>command</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void select(const QModelIndex&,QItemSelectionModel::SelectionFlags)</tt>.</p><p>Selects the model item <i>index</i> using the specified
173
<i>command</i>, and emits <a href="qitemselectionmodel.html#selectionChanged">selectionChanged</a>().</p>
174
<p><b>See also</b> <a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.SelectionFlags</a>.</p>
177
<h3 class="fn"><a name="select-2" />QItemSelectionModel.select (<i>self</i>, <a href="qitemselection.html">QItemSelection</a> <i>selection</i>, <a href="qitemselectionmodel-selectionflags.html">SelectionFlags</a> <i>command</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void select(const QItemSelection&,QItemSelectionModel::SelectionFlags)</tt>.</p><p>Selects the item <i>selection</i> using the specified
178
<i>command</i>, and emits <a href="qitemselectionmodel.html#selectionChanged">selectionChanged</a>().</p>
179
<p><b>See also</b> <a href="qitemselectionmodel.html#SelectionFlag-enum">QItemSelectionModel.SelectionFlag</a>.</p>
182
<h3 class="fn"><a name="selectedColumns" />list-of-QModelIndex QItemSelectionModel.selectedColumns (<i>self</i>, int <i>row</i> = 0)</h3><p>Returns the indexes in the given <i>row</i> for columns where
183
all rows are selected.</p>
184
<p>This function was introduced in Qt 4.2.</p>
185
<p><b>See also</b> <a href="qitemselectionmodel.html#selectedIndexes">selectedIndexes</a>()
186
and <a href="qitemselectionmodel.html#selectedRows">selectedRows</a>().</p>
189
<h3 class="fn"><a name="selectedIndexes" />list-of-QModelIndex QItemSelectionModel.selectedIndexes (<i>self</i>)</h3><p>Returns a list of all selected model item indexes. The list
190
contains no duplicates, and is not sorted.</p>
193
<h3 class="fn"><a name="selectedRows" />list-of-QModelIndex QItemSelectionModel.selectedRows (<i>self</i>, int <i>column</i> = 0)</h3><p>Returns the indexes in the given <i>column</i> for the rows
194
where all columns are selected.</p>
195
<p>This function was introduced in Qt 4.2.</p>
196
<p><b>See also</b> <a href="qitemselectionmodel.html#selectedIndexes">selectedIndexes</a>()
197
and <a href="qitemselectionmodel.html#selectedColumns">selectedColumns</a>().</p>
200
<h3 class="fn"><a name="selection" /><a href="qitemselection.html">QItemSelection</a> QItemSelectionModel.selection (<i>self</i>)</h3><p>Returns the selection ranges stored in the selection model.</p>
203
<h3 class="fn"><a name="setCurrentIndex" />QItemSelectionModel.setCurrentIndex (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>, <a href="qitemselectionmodel-selectionflags.html">SelectionFlags</a> <i>command</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setCurrentIndex(const QModelIndex&,QItemSelectionModel::SelectionFlags)</tt>.</p><p>Sets the model item <i>index</i> to be the current item, and
204
emits <a href="qitemselectionmodel.html#currentChanged">currentChanged</a>(). The
205
current item is used for keyboard navigation and focus indication;
206
it is independent of any selected items, although a selected item
207
can also be the current item.</p>
208
<p>Depending on the specified <i>command</i>, the <i>index</i> can
209
also become part of the current selection.</p>
210
<p><b>See also</b> <a href="qitemselectionmodel.html#currentIndex">currentIndex</a>() and
211
<a href="qitemselectionmodel.html#select">select</a>().</p>
212
<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="currentChanged" />void currentChanged (const QModelIndex&,const QModelIndex&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the current item changes. The
213
<i>previous</i> model item index is replaced by the <i>current</i>
214
index as the selection's current item.</p>
215
<p>Note that this signal will not be emitted when the item model is
217
<p><b>See also</b> <a href="qitemselectionmodel.html#currentIndex">currentIndex</a>(),
218
<a href="qitemselectionmodel.html#setCurrentIndex">setCurrentIndex</a>(),
219
and <a href="qitemselectionmodel.html#selectionChanged">selectionChanged</a>().</p>
222
<h3 class="fn"><a name="currentColumnChanged" />void currentColumnChanged (const QModelIndex&,const QModelIndex&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted if the <i>current</i> item changes and
223
its column is different to the column of the <i>previous</i>
225
<p>Note that this signal will not be emitted when the item model is
227
<p><b>See also</b> <a href="qitemselectionmodel.html#currentChanged">currentChanged</a>(),
228
<a href="qitemselectionmodel.html#currentRowChanged">currentRowChanged</a>(),
229
<a href="qitemselectionmodel.html#currentIndex">currentIndex</a>(),
230
and <a href="qitemselectionmodel.html#setCurrentIndex">setCurrentIndex</a>().</p>
233
<h3 class="fn"><a name="currentRowChanged" />void currentRowChanged (const QModelIndex&,const QModelIndex&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted if the <i>current</i> item changes and
234
its row is different to the row of the <i>previous</i> current
236
<p>Note that this signal will not be emitted when the item model is
238
<p><b>See also</b> <a href="qitemselectionmodel.html#currentChanged">currentChanged</a>(),
239
<a href="qitemselectionmodel.html#currentColumnChanged">currentColumnChanged</a>(),
240
<a href="qitemselectionmodel.html#currentIndex">currentIndex</a>(),
241
and <a href="qitemselectionmodel.html#setCurrentIndex">setCurrentIndex</a>().</p>
244
<h3 class="fn"><a name="selectionChanged" />void selectionChanged (const QItemSelection&,const QItemSelection&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the selection changes. The
245
change in the selection is represented as an item selection of
246
<i>deselected</i> items and an item selection of <i>selected</i>
248
<p>Note the that the current index changes independently from the
249
selection. Also note that this signal will not be emitted when the
250
item model is reset.</p>
251
<p><b>See also</b> <a href="qitemselectionmodel.html#select">select</a>() and <a href="qitemselectionmodel.html#currentChanged">currentChanged</a>().</p>
254
<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>
b'\\ No newline at end of file'