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 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
|
<?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>QTreeView Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTreeView Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTreeView class provides a default model/view implementation
of a tree view. <a href="#details">More...</a></p>
<p>Inherits <a href="qabstractitemview.html">QAbstractItemView</a>.</p><p>Inherited by <a href="qhelpcontentwidget.html">QHelpContentWidget</a> and <a href="qtreewidget.html">QTreeWidget</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtreeview.html#QTreeView">__init__</a></b> (<i>self</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" />bool <b><a href="qtreeview.html#allColumnsShowFocus">allColumnsShowFocus</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#autoExpandDelay">autoExpandDelay</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#collapse">collapse</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#collapseAll">collapseAll</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#columnAt">columnAt</a></b> (<i>self</i>, int <i>x</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#columnCountChanged">columnCountChanged</a></b> (<i>self</i>, int <i>oldCount</i>, int <i>newCount</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#columnMoved">columnMoved</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#columnResized">columnResized</a></b> (<i>self</i>, int <i>column</i>, int <i>oldSize</i>, int <i>newSize</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#columnViewportPosition">columnViewportPosition</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#columnWidth">columnWidth</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#currentChanged">currentChanged</a></b> (<i>self</i>, QModelIndex <i>current</i>, QModelIndex <i>previous</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#dataChanged">dataChanged</a></b> (<i>self</i>, QModelIndex <i>topLeft</i>, QModelIndex <i>bottomRight</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#dragMoveEvent">dragMoveEvent</a></b> (<i>self</i>, QDragMoveEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#drawBranches">drawBranches</a></b> (<i>self</i>, QPainter <i>painter</i>, QRect <i>rect</i>, QModelIndex <i>index</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#drawRow">drawRow</a></b> (<i>self</i>, QPainter <i>painter</i>, QStyleOptionViewItem <i>options</i>, QModelIndex <i>index</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#drawTree">drawTree</a></b> (<i>self</i>, QPainter <i>painter</i>, QRegion <i>region</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#expand">expand</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#expandAll">expandAll</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#expandsOnDoubleClick">expandsOnDoubleClick</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#expandToDepth">expandToDepth</a></b> (<i>self</i>, int <i>depth</i>)</li><li><div class="fn" />QHeaderView <b><a href="qtreeview.html#header">header</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#hideColumn">hideColumn</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#horizontalOffset">horizontalOffset</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#horizontalScrollbarAction">horizontalScrollbarAction</a></b> (<i>self</i>, int <i>action</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#indentation">indentation</a></b> (<i>self</i>)</li><li><div class="fn" />QModelIndex <b><a href="qtreeview.html#indexAbove">indexAbove</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />QModelIndex <b><a href="qtreeview.html#indexAt">indexAt</a></b> (<i>self</i>, QPoint <i>p</i>)</li><li><div class="fn" />QModelIndex <b><a href="qtreeview.html#indexBelow">indexBelow</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#indexRowSizeHint">indexRowSizeHint</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isAnimated">isAnimated</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isColumnHidden">isColumnHidden</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isExpanded">isExpanded</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isFirstColumnSpanned">isFirstColumnSpanned</a></b> (<i>self</i>, int <i>row</i>, QModelIndex <i>parent</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isHeaderHidden">isHeaderHidden</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isIndexHidden">isIndexHidden</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isRowHidden">isRowHidden</a></b> (<i>self</i>, int <i>row</i>, QModelIndex <i>parent</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#isSortingEnabled">isSortingEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#itemsExpandable">itemsExpandable</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#keyboardSearch">keyboardSearch</a></b> (<i>self</i>, QString <i>search</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#keyPressEvent">keyPressEvent</a></b> (<i>self</i>, QKeyEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a></b> (<i>self</i>, QMouseEvent <i>e</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#mouseMoveEvent">mouseMoveEvent</a></b> (<i>self</i>, QMouseEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#mousePressEvent">mousePressEvent</a></b> (<i>self</i>, QMouseEvent <i>e</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#mouseReleaseEvent">mouseReleaseEvent</a></b> (<i>self</i>, QMouseEvent <i>event</i>)</li><li><div class="fn" />QModelIndex <b><a href="qtreeview.html#moveCursor">moveCursor</a></b> (<i>self</i>, QAbstractItemView.CursorAction <i>cursorAction</i>, Qt.KeyboardModifiers <i>modifiers</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent <i>e</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#reexpand">reexpand</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#reset">reset</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#resizeColumnToContents">resizeColumnToContents</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#rootIsDecorated">rootIsDecorated</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#rowHeight">rowHeight</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#rowsAboutToBeRemoved">rowsAboutToBeRemoved</a></b> (<i>self</i>, QModelIndex <i>parent</i>, int <i>start</i>, int <i>end</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#rowsInserted">rowsInserted</a></b> (<i>self</i>, QModelIndex <i>parent</i>, int <i>start</i>, int <i>end</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#rowsRemoved">rowsRemoved</a></b> (<i>self</i>, QModelIndex <i>parent</i>, int <i>first</i>, int <i>last</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#scrollContentsBy">scrollContentsBy</a></b> (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#scrollTo">scrollTo</a></b> (<i>self</i>, QModelIndex <i>index</i>, QAbstractItemView.ScrollHint <i>hint</i> = QAbstractItemView.EnsureVisible)</li><li><div class="fn" /><b><a href="qtreeview.html#selectAll">selectAll</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QModelIndex <b><a href="qtreeview.html#selectedIndexes">selectedIndexes</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#selectionChanged">selectionChanged</a></b> (<i>self</i>, QItemSelection <i>selected</i>, QItemSelection <i>deselected</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setAllColumnsShowFocus">setAllColumnsShowFocus</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setAnimated">setAnimated</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setAutoExpandDelay">setAutoExpandDelay</a></b> (<i>self</i>, int <i>delay</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setColumnHidden">setColumnHidden</a></b> (<i>self</i>, int <i>column</i>, bool <i>hide</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setColumnWidth">setColumnWidth</a></b> (<i>self</i>, int <i>column</i>, int <i>width</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setExpanded">setExpanded</a></b> (<i>self</i>, QModelIndex <i>index</i>, bool <i>expand</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setExpandsOnDoubleClick">setExpandsOnDoubleClick</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setFirstColumnSpanned">setFirstColumnSpanned</a></b> (<i>self</i>, int <i>row</i>, QModelIndex <i>parent</i>, bool <i>span</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setHeader">setHeader</a></b> (<i>self</i>, QHeaderView <i>header</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setHeaderHidden">setHeaderHidden</a></b> (<i>self</i>, bool <i>hide</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setIndentation">setIndentation</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setItemsExpandable">setItemsExpandable</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setModel">setModel</a></b> (<i>self</i>, QAbstractItemModel <i>model</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setRootIndex">setRootIndex</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setRootIsDecorated">setRootIsDecorated</a></b> (<i>self</i>, bool <i>show</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setRowHidden">setRowHidden</a></b> (<i>self</i>, int <i>row</i>, QModelIndex <i>parent</i>, bool <i>hide</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setSelection">setSelection</a></b> (<i>self</i>, QRect <i>rect</i>, QItemSelectionModel.SelectionFlags <i>command</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setSelectionModel">setSelectionModel</a></b> (<i>self</i>, QItemSelectionModel <i>selectionModel</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setSortingEnabled">setSortingEnabled</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setUniformRowHeights">setUniformRowHeights</a></b> (<i>self</i>, bool <i>uniform</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#setWordWrap">setWordWrap</a></b> (<i>self</i>, bool <i>on</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#showColumn">showColumn</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#sizeHintForColumn">sizeHintForColumn</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#sortByColumn">sortByColumn</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#sortByColumn-2">sortByColumn</a></b> (<i>self</i>, int <i>column</i>, Qt.SortOrder <i>order</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#timerEvent">timerEvent</a></b> (<i>self</i>, QTimerEvent <i>event</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#uniformRowHeights">uniformRowHeights</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtreeview.html#updateGeometries">updateGeometries</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtreeview.html#verticalOffset">verticalOffset</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#viewportEvent">viewportEvent</a></b> (<i>self</i>, QEvent <i>event</i>)</li><li><div class="fn" />QRect <b><a href="qtreeview.html#visualRect">visualRect</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />QRegion <b><a href="qtreeview.html#visualRegionForSelection">visualRegionForSelection</a></b> (<i>self</i>, QItemSelection <i>selection</i>)</li><li><div class="fn" />bool <b><a href="qtreeview.html#wordWrap">wordWrap</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qtreeview.html#collapsed">collapsed</a></b> (const QModelIndex&)</li><li><div class="fn" />void <b><a href="qtreeview.html#expanded">expanded</a></b> (const QModelIndex&)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTreeView class provides a default model/view implementation
of a tree view.</p>
<p>A QTreeView implements a tree representation of items from a
model. This class is used to provide standard hierarchical lists
that were previously provided by the <tt>QListView</tt> class, but
using the more flexible approach provided by Qt's model/view
architecture.</p>
<p>The QTreeView 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>.</p>
<p>QTreeView implements the interfaces defined by the <a href="qabstractitemview.html">QAbstractItemView</a> class to allow it to
display data provided by models derived from the <a href="qabstractitemmodel.html">QAbstractItemModel</a> class.</p>
<p>It is simple to construct a tree view displaying data from a
model. In the following example, the contents of a directory are
supplied by a <a href="qfilesystemmodel.html">QFileSystemModel</a>
and displayed as a tree:</p>
<pre class="cpp">
<span class="type"><a href="qfilesystemmodel.html">QFileSystemModel</a></span> <span class="operator">*</span>model <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qfilesystemmodel.html">QFileSystemModel</a></span>;
model<span class="operator">-</span><span class="operator">></span>setRootPath(<span class="type"><a href="qdir.html">QDir</a></span><span class="operator">.</span>currentPath());
<span class="type">QTreeView</span> <span class="operator">*</span>tree <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QTreeView</span>(splitter);
tree<span class="operator">-</span><span class="operator">></span>setModel(model);
</pre>
<p>The model/view architecture ensures that the contents of the
tree view are updated as the model changes.</p>
<p>Items that have children can be in an expanded (children are
visible) or collapsed (children are hidden) state. When this state
changes a <a href="qtreeview.html#collapsed">collapsed</a>() or
<a href="qtreeview.html#expanded">expanded</a>() signal is emitted
with the model index of the relevant item.</p>
<p>The amount of indentation used to indicate levels of hierarchy
is controlled by the <a href="qtreeview.html#indentation-prop">indentation</a> property.</p>
<p>Headers in tree views are constructed using the <a href="qheaderview.html">QHeaderView</a> class and can be hidden using
<tt>header()->hide()</tt>. Note that each header is configured
with its <a href="qheaderview.html#stretchLastSection-prop">stretchLastSection</a>
property set to true, ensuring that the view does not waste any of
the space assigned to it for its header. If this value is set to
true, this property will override the resize mode set on the last
section in the header.</p>
<a id="key-bindings" name="key-bindings" />
<h3>Key Bindings</h3>
<p>QTreeView supports a set of key bindings that enable the user to
navigate in the view and interact with the contents of items:</p>
<table class="generic">
<thead>
<tr class="qt-style">
<th>Key</th>
<th>Action</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td>Up</td>
<td>Moves the cursor to the item in the same column on the previous
row. If the parent of the current item has no more rows to navigate
to, the cursor moves to the relevant item in the last row of the
sibling that precedes the parent.</td>
</tr>
<tr class="even" valign="top">
<td>Down</td>
<td>Moves the cursor to the item in the same column on the next
row. If the parent of the current item has no more rows to navigate
to, the cursor moves to the relevant item in the first row of the
sibling that follows the parent.</td>
</tr>
<tr class="odd" valign="top">
<td>Left</td>
<td>Hides the children of the current item (if present) by
collapsing a branch.</td>
</tr>
<tr class="even" valign="top">
<td>Minus</td>
<td>Same as LeftArrow.</td>
</tr>
<tr class="odd" valign="top">
<td>Right</td>
<td>Reveals the children of the current item (if present) by
expanding a branch.</td>
</tr>
<tr class="even" valign="top">
<td>Plus</td>
<td>Same as RightArrow.</td>
</tr>
<tr class="odd" valign="top">
<td>Asterisk</td>
<td>Expands all children of the current item (if present).</td>
</tr>
<tr class="even" valign="top">
<td>PageUp</td>
<td>Moves the cursor up one page.</td>
</tr>
<tr class="odd" valign="top">
<td>PageDown</td>
<td>Moves the cursor down one page.</td>
</tr>
<tr class="even" valign="top">
<td>Home</td>
<td>Moves the cursor to an item in the same column of the first row
of the first top-level item in the model.</td>
</tr>
<tr class="odd" valign="top">
<td>End</td>
<td>Moves the cursor to an item in the same column of the last row
of the last top-level item in the model.</td>
</tr>
<tr class="even" valign="top">
<td>F2</td>
<td>In editable models, this opens the current item for editing.
The Escape key can be used to cancel the editing process and revert
any changes to the data displayed.</td>
</tr>
</table>
<table class="generic" width="100%">
<tr class="odd" valign="top">
<td><img alt="Screenshot of a Windows XP style tree view" src="images/windowsxp-treeview.png" /></td>
<td><img alt="Screenshot of a Macintosh style tree view" src="images/macintosh-treeview.png" /></td>
<td><img alt="Screenshot of a Plastique style tree view" src="images/plastique-treeview.png" /></td>
</tr>
<tr class="even" valign="top">
<td>A <a href="gallery-windowsxp.html">Windows XP style</a> tree
view.</td>
<td>A <a href="gallery-macintosh.html">Macintosh style</a> tree
view.</td>
<td>A <a href="gallery-plastique.html">Plastique style</a> tree
view.</td>
</tr>
</table>
<a id="improving-performance" name="improving-performance" />
<h3>Improving Performance</h3>
<p>It is possible to give the view hints about the data it is
handling in order to improve its performance when displaying large
numbers of items. One approach that can be taken for views that are
intended to display items with equal heights is to set the <a href="qtreeview.html#uniformRowHeights-prop">uniformRowHeights</a>
property to true.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTreeView" />QTreeView.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a tree view with a <i>parent</i> to represent a
model's data. Use <a href="qtreeview.html#setModel">setModel</a>()
to set the model.</p>
<p><b>See also</b> <a href="qabstractitemmodel.html">QAbstractItemModel</a>.</p>
<h3 class="fn"><a name="allColumnsShowFocus" />bool QTreeView.allColumnsShowFocus (<i>self</i>)</h3><h3 class="fn"><a name="autoExpandDelay" />int QTreeView.autoExpandDelay (<i>self</i>)</h3><h3 class="fn"><a name="collapse" />QTreeView.collapse (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void collapse(const QModelIndex&)</tt>.</p><p>Collapses the model item specified by the <i>index</i>.</p>
<p><b>See also</b> <a href="qtreeview.html#collapsed">collapsed</a>().</p>
<h3 class="fn"><a name="collapseAll" />QTreeView.collapseAll (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void collapseAll()</tt>.</p><p>Collapses all expanded items.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtreeview.html#expandAll">expandAll</a>(), <a href="qtreeview.html#expand">expand</a>(), <a href="qtreeview.html#collapse">collapse</a>(), and <a href="qtreeview.html#setExpanded">setExpanded</a>().</p>
<h3 class="fn"><a name="columnAt" />int QTreeView.columnAt (<i>self</i>, int <i>x</i>)</h3><p>Returns the column in the tree view whose header covers the
<i>x</i> coordinate given.</p>
<h3 class="fn"><a name="columnCountChanged" />QTreeView.columnCountChanged (<i>self</i>, int <i>oldCount</i>, int <i>newCount</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void columnCountChanged(int,int)</tt>.</p><p>Informs the tree view that the number of columns in the tree
view has changed from <i>oldCount</i> to <i>newCount</i>.</p>
<h3 class="fn"><a name="columnMoved" />QTreeView.columnMoved (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void columnMoved()</tt>.</p><p>This slot is called whenever a column has been moved.</p>
<h3 class="fn"><a name="columnResized" />QTreeView.columnResized (<i>self</i>, int <i>column</i>, int <i>oldSize</i>, int <i>newSize</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void columnResized(int,int,int)</tt>.</p><p>This function is called whenever <i>column</i>'s size is changed
in the header. <i>oldSize</i> and <i>newSize</i> give the previous
size and the new size in pixels.</p>
<p><b>See also</b> <a href="qtreeview.html#setColumnWidth">setColumnWidth</a>().</p>
<h3 class="fn"><a name="columnViewportPosition" />int QTreeView.columnViewportPosition (<i>self</i>, int <i>column</i>)</h3><p>Returns the horizontal position of the <i>column</i> in the
viewport.</p>
<h3 class="fn"><a name="columnWidth" />int QTreeView.columnWidth (<i>self</i>, int <i>column</i>)</h3><p>Returns the width of the <i>column</i>.</p>
<p><b>See also</b> <a href="qtreeview.html#resizeColumnToContents">resizeColumnToContents</a>()
and <a href="qtreeview.html#setColumnWidth">setColumnWidth</a>().</p>
<h3 class="fn"><a name="currentChanged" />QTreeView.currentChanged (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>current</i>, <a href="qmodelindex.html">QModelIndex</a> <i>previous</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#currentChanged">QAbstractItemView.currentChanged</a>().</p>
<h3 class="fn"><a name="dataChanged" />QTreeView.dataChanged (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>topLeft</i>, <a href="qmodelindex.html">QModelIndex</a> <i>bottomRight</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void dataChanged(const QModelIndex&,const QModelIndex&)</tt>.</p><p>Reimplemented from <a href="qabstractitemview.html#dataChanged">QAbstractItemView.dataChanged</a>().</p>
<h3 class="fn"><a name="dragMoveEvent" />QTreeView.dragMoveEvent (<i>self</i>, <a href="qdragmoveevent.html">QDragMoveEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#dragMoveEvent">QWidget.dragMoveEvent</a>().</p>
<h3 class="fn"><a name="drawBranches" />QTreeView.drawBranches (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>, <a href="qrect.html">QRect</a> <i>rect</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Draws the branches in the tree view on the same row as the model
item <i>index</i>, using the <i>painter</i> given. The branches are
drawn in the rectangle specified by <i>rect</i>.</p>
<h3 class="fn"><a name="drawRow" />QTreeView.drawRow (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>, <a href="qstyleoptionviewitem.html">QStyleOptionViewItem</a> <i>options</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Draws the row in the tree view that contains the model item
<i>index</i>, using the <i>painter</i> given. The <i>option</i>
control how the item is displayed.</p>
<p><b>See also</b> <a href="qabstractitemview.html#alternatingRowColors-prop">setAlternatingRowColors</a>().</p>
<h3 class="fn"><a name="drawTree" />QTreeView.drawTree (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>, <a href="qregion.html">QRegion</a> <i>region</i>)</h3><p>Draws the part of the tree intersecting the given <i>region</i>
using the specified <i>painter</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtreeview.html#paintEvent">paintEvent</a>().</p>
<h3 class="fn"><a name="expand" />QTreeView.expand (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void expand(const QModelIndex&)</tt>.</p><p>Expands the model item specified by the <i>index</i>.</p>
<p><b>See also</b> <a href="qtreeview.html#expanded">expanded</a>().</p>
<h3 class="fn"><a name="expandAll" />QTreeView.expandAll (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void expandAll()</tt>.</p><p>Expands all expandable items.</p>
<p>Warning: if the model contains a large number of items, this
function will take some time to execute.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtreeview.html#collapseAll">collapseAll</a>(), <a href="qtreeview.html#expand">expand</a>(), <a href="qtreeview.html#collapse">collapse</a>(), and <a href="qtreeview.html#setExpanded">setExpanded</a>().</p>
<h3 class="fn"><a name="expandsOnDoubleClick" />bool QTreeView.expandsOnDoubleClick (<i>self</i>)</h3><h3 class="fn"><a name="expandToDepth" />QTreeView.expandToDepth (<i>self</i>, int <i>depth</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void expandToDepth(int)</tt>.</p><p>Expands all expandable items to the given <i>depth</i>.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also</b> <a href="qtreeview.html#expandAll">expandAll</a>(), <a href="qtreeview.html#collapseAll">collapseAll</a>(), <a href="qtreeview.html#expand">expand</a>(), <a href="qtreeview.html#collapse">collapse</a>(), and <a href="qtreeview.html#setExpanded">setExpanded</a>().</p>
<h3 class="fn"><a name="header" /><a href="qheaderview.html">QHeaderView</a> QTreeView.header (<i>self</i>)</h3><p>Returns the header for the tree view.</p>
<p><b>See also</b> <a href="qtreeview.html#setHeader">setHeader</a>() and <a href="qabstractitemmodel.html#headerData">QAbstractItemModel.headerData</a>().</p>
<h3 class="fn"><a name="hideColumn" />QTreeView.hideColumn (<i>self</i>, int <i>column</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void hideColumn(int)</tt>.</p><p>Hides the <i>column</i> given.</p>
<p><b>Note:</b> This function should only be called after the model
has been initialized, as the view needs to know the number of
columns in order to hide <i>column</i>.</p>
<p><b>See also</b> <a href="qtreeview.html#showColumn">showColumn</a>() and <a href="qtreeview.html#setColumnHidden">setColumnHidden</a>().</p>
<h3 class="fn"><a name="horizontalOffset" />int QTreeView.horizontalOffset (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#horizontalOffset">QAbstractItemView.horizontalOffset</a>().</p>
<p>Returns the horizontal offset of the items in the treeview.</p>
<p>Note that the tree view uses the horizontal header section
positions to determine the positions of columns in the view.</p>
<p><b>See also</b> <a href="qtreeview.html#verticalOffset">verticalOffset</a>().</p>
<h3 class="fn"><a name="horizontalScrollbarAction" />QTreeView.horizontalScrollbarAction (<i>self</i>, int <i>action</i>)</h3><h3 class="fn"><a name="indentation" />int QTreeView.indentation (<i>self</i>)</h3><h3 class="fn"><a name="indexAbove" /><a href="qmodelindex.html">QModelIndex</a> QTreeView.indexAbove (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns the model index of the item above <i>index</i>.</p>
<h3 class="fn"><a name="indexAt" /><a href="qmodelindex.html">QModelIndex</a> QTreeView.indexAt (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#indexAt">QAbstractItemView.indexAt</a>().</p>
<h3 class="fn"><a name="indexBelow" /><a href="qmodelindex.html">QModelIndex</a> QTreeView.indexBelow (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns the model index of the item below <i>index</i>.</p>
<h3 class="fn"><a name="indexRowSizeHint" />int QTreeView.indexRowSizeHint (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns the size hint for the row indicated by <i>index</i>.</p>
<p><b>See also</b> <a href="qtreeview.html#sizeHintForColumn">sizeHintForColumn</a>() and
<a href="qtreeview.html#uniformRowHeights-prop">uniformRowHeights</a>().</p>
<h3 class="fn"><a name="isAnimated" />bool QTreeView.isAnimated (<i>self</i>)</h3><h3 class="fn"><a name="isColumnHidden" />bool QTreeView.isColumnHidden (<i>self</i>, int <i>column</i>)</h3><p>Returns true if the <i>column</i> is hidden; otherwise returns
false.</p>
<p><b>See also</b> <a href="qtreeview.html#hideColumn">hideColumn</a>() and <a href="qtreeview.html#isRowHidden">isRowHidden</a>().</p>
<h3 class="fn"><a name="isExpanded" />bool QTreeView.isExpanded (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns true if the model item <i>index</i> is expanded;
otherwise returns false.</p>
<p><b>See also</b> <a href="qtreeview.html#expand">expand</a>(),
<a href="qtreeview.html#expanded">expanded</a>(), and <a href="qtreeview.html#setExpanded">setExpanded</a>().</p>
<h3 class="fn"><a name="isFirstColumnSpanned" />bool QTreeView.isFirstColumnSpanned (<i>self</i>, int <i>row</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>)</h3><p>Returns true if the item in first column in the given <i>row</i>
of the <i>parent</i> is spanning all the columns; otherwise returns
false.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also</b> <a href="qtreeview.html#setFirstColumnSpanned">setFirstColumnSpanned</a>().</p>
<h3 class="fn"><a name="isHeaderHidden" />bool QTreeView.isHeaderHidden (<i>self</i>)</h3><h3 class="fn"><a name="isIndexHidden" />bool QTreeView.isIndexHidden (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#isIndexHidden">QAbstractItemView.isIndexHidden</a>().</p>
<h3 class="fn"><a name="isRowHidden" />bool QTreeView.isRowHidden (<i>self</i>, int <i>row</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>)</h3><p>Returns true if the item in the given <i>row</i> of the
<i>parent</i> is hidden; otherwise returns false.</p>
<p><b>See also</b> <a href="qtreeview.html#setRowHidden">setRowHidden</a>() and <a href="qtreeview.html#isColumnHidden">isColumnHidden</a>().</p>
<h3 class="fn"><a name="isSortingEnabled" />bool QTreeView.isSortingEnabled (<i>self</i>)</h3><h3 class="fn"><a name="itemsExpandable" />bool QTreeView.itemsExpandable (<i>self</i>)</h3><h3 class="fn"><a name="keyboardSearch" />QTreeView.keyboardSearch (<i>self</i>, QString <i>search</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#keyboardSearch">QAbstractItemView.keyboardSearch</a>().</p>
<h3 class="fn"><a name="keyPressEvent" />QTreeView.keyPressEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget.keyPressEvent</a>().</p>
<h3 class="fn"><a name="mouseDoubleClickEvent" />QTreeView.mouseDoubleClickEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>e</i>)</h3><p>Reimplemented from <a href="qwidget.html#mouseDoubleClickEvent">QWidget.mouseDoubleClickEvent</a>().</p>
<h3 class="fn"><a name="mouseMoveEvent" />QTreeView.mouseMoveEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#mouseMoveEvent">QWidget.mouseMoveEvent</a>().</p>
<h3 class="fn"><a name="mousePressEvent" />QTreeView.mousePressEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>e</i>)</h3><p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget.mousePressEvent</a>().</p>
<h3 class="fn"><a name="mouseReleaseEvent" />QTreeView.mouseReleaseEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#mouseReleaseEvent">QWidget.mouseReleaseEvent</a>().</p>
<h3 class="fn"><a name="moveCursor" /><a href="qmodelindex.html">QModelIndex</a> QTreeView.moveCursor (<i>self</i>, <a href="qabstractitemview.html#CursorAction-enum">QAbstractItemView.CursorAction</a> <i>cursorAction</i>, <a href="qt-keyboardmodifiers.html">Qt.KeyboardModifiers</a> <i>modifiers</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#moveCursor">QAbstractItemView.moveCursor</a>().</p>
<p>Move the cursor in the way described by <i>cursorAction</i>,
using the information provided by the button <i>modifiers</i>.</p>
<h3 class="fn"><a name="paintEvent" />QTreeView.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a> <i>e</i>)</h3><p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget.paintEvent</a>().</p>
<h3 class="fn"><a name="reexpand" />QTreeView.reexpand (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void reexpand()</tt>.</p><h3 class="fn"><a name="reset" />QTreeView.reset (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#reset">QAbstractItemView.reset</a>().</p>
<h3 class="fn"><a name="resizeColumnToContents" />QTreeView.resizeColumnToContents (<i>self</i>, int <i>column</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void resizeColumnToContents(int)</tt>.</p><p>Resizes the <i>column</i> given to the size of its contents.</p>
<p><b>See also</b> <a href="qtreeview.html#columnWidth">columnWidth</a>() and <a href="qtreeview.html#setColumnWidth">setColumnWidth</a>().</p>
<h3 class="fn"><a name="rootIsDecorated" />bool QTreeView.rootIsDecorated (<i>self</i>)</h3><h3 class="fn"><a name="rowHeight" />int QTreeView.rowHeight (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns the height of the row indicated by the given
<i>index</i>.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also</b> <a href="qtreeview.html#indexRowSizeHint">indexRowSizeHint</a>().</p>
<h3 class="fn"><a name="rowsAboutToBeRemoved" />QTreeView.rowsAboutToBeRemoved (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>, int <i>start</i>, int <i>end</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#rowsAboutToBeRemoved">QAbstractItemView.rowsAboutToBeRemoved</a>().</p>
<p>Informs the view that the rows from the <i>start</i> row to the
<i>end</i> row inclusive are about to removed from the given
<i>parent</i> model item.</p>
<h3 class="fn"><a name="rowsInserted" />QTreeView.rowsInserted (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>, int <i>start</i>, int <i>end</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#rowsInserted">QAbstractItemView.rowsInserted</a>().</p>
<p>Informs the view that the rows from the <i>start</i> row to the
<i>end</i> row inclusive have been inserted into the <i>parent</i>
model item.</p>
<h3 class="fn"><a name="rowsRemoved" />QTreeView.rowsRemoved (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>, int <i>first</i>, int <i>last</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void rowsRemoved(const QModelIndex&,int,int)</tt>.</p><p>Informs the view that the rows from the <i>start</i> row to the
<i>end</i> row inclusive have been removed from the given
<i>parent</i> model item.</p>
<p>This function was introduced in Qt 4.1.</p>
<h3 class="fn"><a name="scrollContentsBy" />QTreeView.scrollContentsBy (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</h3><p>Reimplemented from <a href="qabstractscrollarea.html#scrollContentsBy">QAbstractScrollArea.scrollContentsBy</a>().</p>
<p>Scrolls the contents of the tree view by (<i>dx</i>,
<i>dy</i>).</p>
<h3 class="fn"><a name="scrollTo" />QTreeView.scrollTo (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>, <a href="qabstractitemview.html#ScrollHint-enum">QAbstractItemView.ScrollHint</a> <i>hint</i> = QAbstractItemView.EnsureVisible)</h3><p>Reimplemented from <a href="qabstractitemview.html#scrollTo">QAbstractItemView.scrollTo</a>().</p>
<p>Scroll the contents of the tree view until the given model item
<i>index</i> is visible. The <i>hint</i> parameter specifies more
precisely where the item should be located after the operation. If
any of the parents of the model item are collapsed, they will be
expanded to ensure that the model item is visible.</p>
<h3 class="fn"><a name="selectAll" />QTreeView.selectAll (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void selectAll()</tt>.</p><p>Reimplemented from <a href="qabstractitemview.html#selectAll">QAbstractItemView.selectAll</a>().</p>
<h3 class="fn"><a name="selectedIndexes" />list-of-QModelIndex QTreeView.selectedIndexes (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#selectedIndexes">QAbstractItemView.selectedIndexes</a>().</p>
<h3 class="fn"><a name="selectionChanged" />QTreeView.selectionChanged (<i>self</i>, <a href="qitemselection.html">QItemSelection</a> <i>selected</i>, <a href="qitemselection.html">QItemSelection</a> <i>deselected</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#selectionChanged">QAbstractItemView.selectionChanged</a>().</p>
<h3 class="fn"><a name="setAllColumnsShowFocus" />QTreeView.setAllColumnsShowFocus (<i>self</i>, bool <i>enable</i>)</h3><h3 class="fn"><a name="setAnimated" />QTreeView.setAnimated (<i>self</i>, bool <i>enable</i>)</h3><h3 class="fn"><a name="setAutoExpandDelay" />QTreeView.setAutoExpandDelay (<i>self</i>, int <i>delay</i>)</h3><h3 class="fn"><a name="setColumnHidden" />QTreeView.setColumnHidden (<i>self</i>, int <i>column</i>, bool <i>hide</i>)</h3><p>If <i>hide</i> is true the <i>column</i> is hidden, otherwise
the <i>column</i> is shown.</p>
<p><b>See also</b> <a href="qtreeview.html#isColumnHidden">isColumnHidden</a>(), <a href="qtreeview.html#hideColumn">hideColumn</a>(), and <a href="qtreeview.html#setRowHidden">setRowHidden</a>().</p>
<h3 class="fn"><a name="setColumnWidth" />QTreeView.setColumnWidth (<i>self</i>, int <i>column</i>, int <i>width</i>)</h3><p>Sets the width of the given <i>column</i> to the <i>width</i>
specified.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtreeview.html#columnWidth">columnWidth</a>() and <a href="qtreeview.html#resizeColumnToContents">resizeColumnToContents</a>().</p>
<h3 class="fn"><a name="setExpanded" />QTreeView.setExpanded (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>, bool <i>expand</i>)</h3><p>Sets the item referred to by <i>index</i> to either collapse or
expanded, depending on the value of <i>expanded</i>.</p>
<p><b>See also</b> <a href="qtreeview.html#expanded">expanded</a>(), <a href="qtreeview.html#expand">expand</a>(), and <a href="qtreeview.html#isExpanded">isExpanded</a>().</p>
<h3 class="fn"><a name="setExpandsOnDoubleClick" />QTreeView.setExpandsOnDoubleClick (<i>self</i>, bool <i>enable</i>)</h3><h3 class="fn"><a name="setFirstColumnSpanned" />QTreeView.setFirstColumnSpanned (<i>self</i>, int <i>row</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>, bool <i>span</i>)</h3><p>If <i>span</i> is true the item in the first column in the
<i>row</i> with the given <i>parent</i> is set to span all columns,
otherwise all items on the <i>row</i> are shown.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also</b> <a href="qtreeview.html#isFirstColumnSpanned">isFirstColumnSpanned</a>().</p>
<h3 class="fn"><a name="setHeader" />QTreeView.setHeader (<i>self</i>, <a href="qheaderview.html">QHeaderView</a> <i>header</i>)</h3><p>The <i>header</i> argument has it's ownership transferred to Qt.</p><p>Sets the header for the tree view, to the given
<i>header</i>.</p>
<p>The view takes ownership over the given <i>header</i> and
deletes it when a new header is set.</p>
<p><b>See also</b> <a href="qabstractitemmodel.html#headerData">QAbstractItemModel.headerData</a>().</p>
<h3 class="fn"><a name="setHeaderHidden" />QTreeView.setHeaderHidden (<i>self</i>, bool <i>hide</i>)</h3><h3 class="fn"><a name="setIndentation" />QTreeView.setIndentation (<i>self</i>, int <i>i</i>)</h3><h3 class="fn"><a name="setItemsExpandable" />QTreeView.setItemsExpandable (<i>self</i>, bool <i>enable</i>)</h3><h3 class="fn"><a name="setModel" />QTreeView.setModel (<i>self</i>, <a href="qabstractitemmodel.html">QAbstractItemModel</a> <i>model</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#setModel">QAbstractItemView.setModel</a>().</p>
<h3 class="fn"><a name="setRootIndex" />QTreeView.setRootIndex (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#setRootIndex">QAbstractItemView.setRootIndex</a>().</p>
<h3 class="fn"><a name="setRootIsDecorated" />QTreeView.setRootIsDecorated (<i>self</i>, bool <i>show</i>)</h3><h3 class="fn"><a name="setRowHidden" />QTreeView.setRowHidden (<i>self</i>, int <i>row</i>, <a href="qmodelindex.html">QModelIndex</a> <i>parent</i>, bool <i>hide</i>)</h3><p>If <i>hide</i> is true the <i>row</i> with the given
<i>parent</i> is hidden, otherwise the <i>row</i> is shown.</p>
<p><b>See also</b> <a href="qtreeview.html#isRowHidden">isRowHidden</a>() and <a href="qtreeview.html#setColumnHidden">setColumnHidden</a>().</p>
<h3 class="fn"><a name="setSelection" />QTreeView.setSelection (<i>self</i>, <a href="qrect.html">QRect</a> <i>rect</i>, <a href="qitemselectionmodel-selectionflags.html">QItemSelectionModel.SelectionFlags</a> <i>command</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#setSelection">QAbstractItemView.setSelection</a>().</p>
<p>Applies the selection <i>command</i> to the items in or touched
by the rectangle, <i>rect</i>.</p>
<p><b>See also</b> <a href="qabstractitemview.html#selectionCommand">selectionCommand</a>().</p>
<h3 class="fn"><a name="setSelectionModel" />QTreeView.setSelectionModel (<i>self</i>, <a href="qitemselectionmodel.html">QItemSelectionModel</a> <i>selectionModel</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#setSelectionModel">QAbstractItemView.setSelectionModel</a>().</p>
<h3 class="fn"><a name="setSortingEnabled" />QTreeView.setSortingEnabled (<i>self</i>, bool <i>enable</i>)</h3><h3 class="fn"><a name="setUniformRowHeights" />QTreeView.setUniformRowHeights (<i>self</i>, bool <i>uniform</i>)</h3><h3 class="fn"><a name="setWordWrap" />QTreeView.setWordWrap (<i>self</i>, bool <i>on</i>)</h3><h3 class="fn"><a name="showColumn" />QTreeView.showColumn (<i>self</i>, int <i>column</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void showColumn(int)</tt>.</p><p>Shows the given <i>column</i> in the tree view.</p>
<p><b>See also</b> <a href="qtreeview.html#hideColumn">hideColumn</a>() and <a href="qtreeview.html#setColumnHidden">setColumnHidden</a>().</p>
<h3 class="fn"><a name="sizeHintForColumn" />int QTreeView.sizeHintForColumn (<i>self</i>, int <i>column</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#sizeHintForColumn">QAbstractItemView.sizeHintForColumn</a>().</p>
<p>Returns the size hint for the <i>column</i>'s width or -1 if
there is no model.</p>
<p>If you need to set the width of a given column to a fixed value,
call <a href="qheaderview.html#resizeSection">QHeaderView.resizeSection</a>()
on the view's header.</p>
<p>If you reimplement this function in a subclass, note that the
value you return is only used when <a href="qtreeview.html#resizeColumnToContents">resizeColumnToContents</a>()
is called. In that case, if a larger column width is required by
either the view's header or the item delegate, that width will be
used instead.</p>
<p><b>See also</b> <a href="qwidget.html#sizeHint-prop">QWidget.sizeHint</a> and <a href="qtreeview.html#header">header</a>().</p>
<h3 class="fn"><a name="sortByColumn" />QTreeView.sortByColumn (<i>self</i>, int <i>column</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void sortByColumn(int)</tt>.</p><p>Sets the model up for sorting by the values in the given
<i>column</i> and <i>order</i>.</p>
<p><i>column</i> may be -1, in which case no sort indicator will be
shown and the model will return to its natural, unsorted order.
Note that not all models support this and may even crash in this
case.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtreeview.html#sortingEnabled-prop">sortingEnabled</a>.</p>
<h3 class="fn"><a name="sortByColumn-2" />QTreeView.sortByColumn (<i>self</i>, int <i>column</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i>)</h3><h3 class="fn"><a name="timerEvent" />QTreeView.timerEvent (<i>self</i>, <a href="qtimerevent.html">QTimerEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qobject.html#timerEvent">QObject.timerEvent</a>().</p>
<h3 class="fn"><a name="uniformRowHeights" />bool QTreeView.uniformRowHeights (<i>self</i>)</h3><h3 class="fn"><a name="updateGeometries" />QTreeView.updateGeometries (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#updateGeometries">QAbstractItemView.updateGeometries</a>().</p>
<h3 class="fn"><a name="verticalOffset" />int QTreeView.verticalOffset (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#verticalOffset">QAbstractItemView.verticalOffset</a>().</p>
<p>Returns the vertical offset of the items in the tree view.</p>
<p><b>See also</b> <a href="qtreeview.html#horizontalOffset">horizontalOffset</a>().</p>
<h3 class="fn"><a name="viewportEvent" />bool QTreeView.viewportEvent (<i>self</i>, <a href="qevent.html">QEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qabstractscrollarea.html#viewportEvent">QAbstractScrollArea.viewportEvent</a>().</p>
<h3 class="fn"><a name="visualRect" /><a href="qrect.html">QRect</a> QTreeView.visualRect (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#visualRect">QAbstractItemView.visualRect</a>().</p>
<p>Returns the rectangle on the viewport occupied by the item at
<i>index</i>. If the index is not visible or explicitly hidden, the
returned rectangle is invalid.</p>
<h3 class="fn"><a name="visualRegionForSelection" /><a href="qregion.html">QRegion</a> QTreeView.visualRegionForSelection (<i>self</i>, <a href="qitemselection.html">QItemSelection</a> <i>selection</i>)</h3><p>Reimplemented from <a href="qabstractitemview.html#visualRegionForSelection">QAbstractItemView.visualRegionForSelection</a>().</p>
<p>Returns the rectangle from the viewport of the items in the
given <i>selection</i>.</p>
<p>Since 4.7, the returned region only contains rectangles
intersecting (or included in) the viewport.</p>
<h3 class="fn"><a name="wordWrap" />bool QTreeView.wordWrap (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="collapsed" />void collapsed (const QModelIndex&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the item specified by <i>index</i>
is collapsed.</p>
<h3 class="fn"><a name="expanded" />void expanded (const QModelIndex&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the item specified by <i>index</i>
is expanded.</p>
<p><b>See also</b> <a href="qtreeview.html#setExpanded">setExpanded</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.9.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.2</td></tr></table></div></address></body></html>
|