Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QTreeView

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QWidget
                          com.trolltech.qt.gui.QFrame
                              com.trolltech.qt.gui.QAbstractScrollArea
                                  com.trolltech.qt.gui.QAbstractItemView
                                      com.trolltech.qt.gui.QTreeView

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

Direct Known Subclasses:
  QTreeWidget

    public class QTreeView

extends QAbstractItemView

The QTreeView class provides a default model/view implementation of a tree view. 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 `QListView` class, but using the more flexible approach provided by Qt's model/view architecture.

The QTreeView class is one of the Model/View Classes and is part of Qt's model/view framework.

QTreeView implements the interfaces defined by the `QAbstractItemView` class to allow it to display data provided by models derived from the `QAbstractItemModel` class.

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 `QDirModel` and displayed as a tree:

        QDirModel model = new QDirModel();

        QTreeView tree = new QTreeView(splitter);

        tree.setModel(model);

The model/view architecture ensures that the contents of the tree view are updated as the model changes.

Items that have children can be in an expanded (children are visible) or collapsed (children are hidden) state. When this state changes a `collapsed()` or `expanded()` signal is emitted with the model index of the relevant item.

The amount of indentation used to indicate levels of hierarchy is controlled by the `indentation` property.

Headers in tree views are constructed using the `QHeaderView` class and can be hidden using `header()->hide()`. Note that each header is configured with its `stretchLastSection` 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.

## Key Bindings

QTreeView supports a set of key bindings that enable the user to navigate in the view and interact with the contents of items:

Key | Action
--- | ---
Up | 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.
Down | 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.
Left | Hides the children of the current item (if present) by collapsing a branch.
Minus | Same as LeftArrow.
Right | Reveals the children of the current item (if present) by expanding a branch.
Plus | Same as RightArrow.
Asterisk | Expands all children of the current item (if present).
PageUp | Moves the cursor up one page.
PageDown | Moves the cursor down one page.
Home | Moves the cursor to an item in the same column of the first row of the first top-level item in the model.
End | Moves the cursor to an item in the same column of the last row of the last top-level item in the model.
F2 | 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.

A Windows XP style tree view. | A Macintosh style tree view. | A Plastique style tree view.

## Improving Performance

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 `uniformRowHeights` property to true.

See also:
  `QListView`, `QTreeWidget`, View Classes, `QAbstractItemModel`, `QAbstractItemView`, and Dir View Example.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAbstractItemView
`QAbstractItemView.CursorAction, QAbstractItemView.DragDropMode, QAbstractItemView.DropIndicatorPosition, QAbstractItemView.EditTrigger, QAbstractItemView.EditTriggers, QAbstractItemView.ScrollHint, QAbstractItemView.ScrollMode, QAbstractItemView.SelectionBehavior, QAbstractItemView.SelectionMode, QAbstractItemView.State`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame
`QFrame.Shadow, QFrame.Shape, QFrame.StyleMask`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
`QWidget.RenderFlag, QWidget.RenderFlags`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal1` | `collapsed` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `expanded` This signal takes 1 generic argument(s).

Fields inherited from class com.trolltech.qt.gui.QAbstractItemView
`activated, clicked, doubleClicked, entered, pressed, viewportEntered`

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QTreeView()` Constructs a table view with a `parent` to represent a model's data.
`QTreeView(QWidget parent)` Constructs a table view with a `parent` to represent a model's data.

Method Summary
`boolean` | `allColumnsShowFocus()` This property holds whether items should show keyboard focus using all columns.
`int` | `autoExpandDelay()` This property holds The delay time before items in a tree are opened during a drag and drop operation.
`void` | `collapse(com.trolltech.qt.core.QModelIndex index)` Collapses the model item specified by the `index`.
`void` | `collapseAll()` Collapses all expanded items.
`int` | `columnAt(int x)` Returns the column in the tree view whose header covers the `x` coordinate given.
`protected void` | `columnCountChanged(int oldCount, int newCount)` Informs the tree view that the number of columns in the tree view has changed from `oldCount` to `newCount`.
`protected void` | `columnMoved()` This slot is called whenever a column has been moved.
`protected void` | `columnResized(int column, int oldSize, int newSize)` This function is called whenever `column`'s size is changed in the header.
`int` | `columnViewportPosition(int column)` Returns the horizontal position of the `column` in the viewport.
`int` | `columnWidth(int column)` Returns the width of the `column`.
`protected void` | `drawBranches(QPainter painter, QRect rect, com.trolltech.qt.core.QModelIndex index)` Draws the branches in the tree view on the same row as the model item `index`, using the `painter` given.
`protected void` | `drawRow(QPainter painter, QStyleOptionViewItem options, com.trolltech.qt.core.QModelIndex index)` Draws the row in the tree view that contains the model item `index`, using the `painter` given.
`protected void` | `drawTree(QPainter painter, QRegion region)` Draws the part of the tree intersecting the given `region` using the specified `painter`.
`void` | `expand(com.trolltech.qt.core.QModelIndex index)` Expands the model item specified by the `index`.
`void` | `expandAll()` Expands all expandable items.
`boolean` | `expandsOnDoubleClick()` This property holds whether the items can be expanded by double-clicking.
`void` | `expandToDepth(int depth)` Expands all expandable items to the given `depth`.
`QHeaderView` | `header()` Returns the header for the tree view.
`void` | `hideColumn(int column)` Hides the `column` given.
`int` | `indentation()` This property holds indentation of the items in the tree view.
`com.trolltech.qt.core.QModelIndex` | `indexAbove(com.trolltech.qt.core.QModelIndex index)` Returns the model index of the item above `index`.
`com.trolltech.qt.core.QModelIndex` | `indexBelow(com.trolltech.qt.core.QModelIndex index)` Returns the model index of the item below `index`.
`protected int` | `indexRowSizeHint(com.trolltech.qt.core.QModelIndex index)` Returns the size hint for the row indicated by `index`.
`boolean` | `isAnimated()` This property holds whether animations are enabled.
`boolean` | `isColumnHidden(int column)` Returns true if the `column` is hidden; otherwise returns false.
`boolean` | `isExpanded(com.trolltech.qt.core.QModelIndex index)` Returns true if the model item `index` is expanded; otherwise returns false.
`boolean` | `isFirstColumnSpanned(int row, com.trolltech.qt.core.QModelIndex parent)` Returns true if the item in first column in the given `row` of the `parent` is spanning all the columns; otherwise returns false.
`boolean` | `isHeaderHidden()` This property holds whether the header is shown or not.
`boolean` | `isRowHidden(int row, com.trolltech.qt.core.QModelIndex parent)` Returns true if the item in the given `row` of the `parent` is hidden; otherwise returns false.
`boolean` | `isSortingEnabled()` This property holds whether sorting is enabled.
`boolean` | `itemsExpandable()` This property holds whether the items are expandable by the user.
`void` | `resizeColumnToContents(int column)` Resizes the `column` given to the size of its contents.
`boolean` | `rootIsDecorated()` This property holds whether to show controls for expanding and collapsing top-level items.
`protected int` | `rowHeight(com.trolltech.qt.core.QModelIndex index)` Returns the height of the row indicated by the given `index`.
`protected void` | `rowsRemoved(com.trolltech.qt.core.QModelIndex parent, int first, int last)` Informs the view that the rows from the `start` row to the `end` row inclusive have been removed from the given `parent` model item.
`void` | `setAllColumnsShowFocus(boolean enable)` This property holds whether items should show keyboard focus using all columns.
`void` | `setAnimated(boolean enable)` This property holds whether animations are enabled.
`void` | `setAutoExpandDelay(int delay)` This property holds The delay time before items in a tree are opened during a drag and drop operation.
`void` | `setColumnHidden(int column, boolean hide)` If `hide` is true the `column` is hidden, otherwise the `column` is shown.
`void` | `setColumnWidth(int column, int width)` Sets the width of the given `column` to the `width` specified.
`void` | `setExpanded(com.trolltech.qt.core.QModelIndex index, boolean expand)` Sets the item referred to by `index` to either collapse or expanded, depending on the value of `expanded`.
`void` | `setExpandsOnDoubleClick(boolean enable)` This property holds whether the items can be expanded by double-clicking.
`void` | `setFirstColumnSpanned(int row, com.trolltech.qt.core.QModelIndex parent, boolean span)` If `span` is true the item in the first column in the `row` with the given `parent` is set to span all columns, otherwise all items on the `row` are shown.
`void` | `setHeader(QHeaderView header)` Sets the header for the tree view, to the given `header`.
`void` | `setHeaderHidden(boolean hide)` This property holds whether the header is shown or not.
`void` | `setIndentation(int i)` This property holds indentation of the items in the tree view.
`void` | `setItemsExpandable(boolean enable)` This property holds whether the items are expandable by the user.
`void` | `setRootIsDecorated(boolean show)` This property holds whether to show controls for expanding and collapsing top-level items.
`void` | `setRowHidden(int row, com.trolltech.qt.core.QModelIndex parent, boolean hide)` If `hide` is true the `row` with the given `parent` is hidden, otherwise the `row` is shown.
`void` | `setSortingEnabled(boolean enable)` This property holds whether sorting is enabled.
`void` | `setUniformRowHeights(boolean uniform)` This property holds whether all items in the treeview have the same height.
`void` | `setWordWrap(boolean on)` This property holds the item text word-wrapping policy.
`void` | `showColumn(int column)` Shows the given `column` in the tree view.
`void` | `sortByColumn(int column, Qt.SortOrder order)` Sets the model up for sorting by the values in the given `column` and `order`.
`boolean` | `uniformRowHeights()` This property holds whether all items in the treeview have the same height.
`boolean` | `wordWrap()` This property holds the item text word-wrapping policy.

Methods inherited from class com.trolltech.qt.gui.QAbstractItemView
`alternatingRowColors, autoScrollMargin, clearSelection, closeEditor, closePersistentEditor, commitData, currentChanged, currentIndex, dataChanged, dirtyRegionOffset, dragDropMode, dragDropOverwriteMode, dragEnabled, dropIndicatorPosition, edit, edit, editorDestroyed, editTriggers, executeDelayedItemsLayout, hasAutoScroll, horizontalOffset, horizontalScrollMode, iconSize, indexAt, indexWidget, isIndexHidden, itemDelegate, itemDelegate, itemDelegateForColumn, itemDelegateForRow, keyboardSearch, model, moveCursor, openPersistentEditor, reset, rootIndex, rowsAboutToBeRemoved, rowsInserted, scheduleDelayedItemsLayout, scrollDirtyRegion, scrollTo, scrollTo, scrollToBottom, scrollToTop, selectAll, selectedIndexes, selectionBehavior, selectionChanged, selectionCommand, selectionCommand, selectionMode, selectionModel, setAlternatingRowColors, setAutoScroll, setAutoScrollMargin, setCurrentIndex, setDirtyRegion, setDragDropMode, setDragDropOverwriteMode, setDragEnabled, setDropIndicatorShown, setEditTriggers, setEditTriggers, setHorizontalScrollMode, setIconSize, setIndexWidget, setItemDelegate, setItemDelegateForColumn, setItemDelegateForRow, setModel, setRootIndex, setSelection, setSelectionBehavior, setSelectionMode, setSelectionModel, setState, setTabKeyNavigation, setTextElideMode, setVerticalScrollMode, showDropIndicator, sizeHintForColumn, sizeHintForIndex, sizeHintForRow, startDrag, startDrag, state, tabKeyNavigation, textElideMode, update, updateGeometries, verticalOffset, verticalScrollMode, viewOptions, visualRect, visualRegionForSelection`

Methods inherited from class com.trolltech.qt.gui.QAbstractScrollArea
`addScrollBarWidget, addScrollBarWidget, cornerWidget, horizontalScrollBar, horizontalScrollBarPolicy, maximumViewportSize, scrollBarWidgets, scrollBarWidgets, scrollContentsBy, setCornerWidget, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setupViewport, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportMargins, verticalScrollBar, verticalScrollBarPolicy, viewport, viewportEvent`

Methods inherited from class com.trolltech.qt.gui.QFrame
`frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth`

Methods inherited from class com.trolltech.qt.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### collapsed

    public final QSignalEmitter.Signal1 collapsed

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QModelIndex(named: index)>:

  This signal is emitted when the item specified by `index` is collapsed.

### expanded

    public final QSignalEmitter.Signal1 expanded

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QModelIndex(named: index)>:

  This signal is emitted when the item specified by `index` is expanded.

See also:
  `setExpanded()`.

Constructor Detail

### QTreeView

    public QTreeView()

  Constructs a table view with a `parent` to represent a model's data. Use `setModel()` to set the model.

See also:
  `QAbstractItemModel`.

### QTreeView

    public QTreeView(QWidget parent)

  Constructs a table view with a `parent` to represent a model's data. Use `setModel()` to set the model.

See also:
  `QAbstractItemModel`.

Method Detail

### allColumnsShowFocus

    public final boolean allColumnsShowFocus()

  This property holds whether items should show keyboard focus using all columns. If this property is true all columns will show focus, otherwise only one column will show focus.

  The default is false.

### autoExpandDelay

    public final int autoExpandDelay()

  This property holds The delay time before items in a tree are opened during a drag and drop operation. This property holds the amount of time in milliseconds that the user must wait over a node before that node will automatically open or close. If the time is set to less then 0 then it will not be activated.

  By default, this property has a value of -1, meaning that auto-expansion is disabled.

### collapse

    public final void collapse(com.trolltech.qt.core.QModelIndex index)

  Collapses the model item specified by the `index`.

See also:
  `collapsed()` .

### collapseAll

    public final void collapseAll()

  Collapses all expanded items.

See also:
  `expandAll()`, `expand()`, `collapse()`, and `setExpanded()`.

### columnAt

    public final int columnAt(int x)

  Returns the column in the tree view whose header covers the `x` coordinate given.

### columnCountChanged

    protected final void columnCountChanged(int oldCount,
                                            int newCount)

  Informs the tree view that the number of columns in the tree view has changed from `oldCount` to `newCount`.

### columnMoved

    protected final void columnMoved()

  This slot is called whenever a column has been moved.

### columnResized

    protected final void columnResized(int column,
                                       int oldSize,
                                       int newSize)

  This function is called whenever `column`'s size is changed in the header. `oldSize` and `newSize` give the previous size and the new size in pixels.

See also:
  `setColumnWidth()`.

### columnViewportPosition

    public final int columnViewportPosition(int column)

  Returns the horizontal position of the `column` in the viewport.

### columnWidth

    public final int columnWidth(int column)

  Returns the width of the `column`.

See also:
  `resizeColumnToContents()`, and `setColumnWidth()`.

### drawTree

    protected final void drawTree(QPainter painter,
                                  QRegion region)

  Draws the part of the tree intersecting the given `region` using the specified `painter`.

See also:
  `paintEvent()`.

### expand

    public final void expand(com.trolltech.qt.core.QModelIndex index)

  Expands the model item specified by the `index`.

See also:
  `expanded()` .

### expandAll

    public final void expandAll()

  Expands all expandable items.

  Warning: if the model contains a large number of items, this function will be take time to execute.

See also:
  `collapseAll()`, `expand()`, `collapse()`, and `setExpanded()`.

### expandToDepth

    public final void expandToDepth(int depth)

  Expands all expandable items to the given `depth`.

See also:
  `expandAll()`, `collapseAll()`, `expand()`, `collapse()`, and `setExpanded()`.

### expandsOnDoubleClick

    public final boolean expandsOnDoubleClick()

  This property holds whether the items can be expanded by double-clicking. This property holds whether the user can expand and collapse items by double-clicking. The default value is true.

See also:
  `itemsExpandable`.

### header

    public final QHeaderView header()

  Returns the header for the tree view.

See also:
  `setHeader()`, and `QAbstractItemModel::headerData()`.

### hideColumn

    public final void hideColumn(int column)

  Hides the `column` given.

  Note: 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 `column`.

See also:
  `showColumn()`, and `setColumnHidden()`.

### indentation

    public final int indentation()

  This property holds indentation of the items in the tree view. This property holds the indentation measured in pixels of the items for each level in the tree view. For top-level items, the indentation specifies the horizontal distance from the viewport edge to the items in the first column; for child items, it specifies their indentation from their parent items.

  By default, this property has a value of 20.

### indexAbove

    public final com.trolltech.qt.core.QModelIndex indexAbove(com.trolltech.qt.core.QModelIndex index)

  Returns the model index of the item above `index`.

### indexBelow

    public final com.trolltech.qt.core.QModelIndex indexBelow(com.trolltech.qt.core.QModelIndex index)

  Returns the model index of the item below `index`.

### indexRowSizeHint

    protected final int indexRowSizeHint(com.trolltech.qt.core.QModelIndex index)

  Returns the size hint for the row indicated by `index`.

See also:
  sizeHintForColumn(), and `uniformRowHeights()`.

### isAnimated

    public final boolean isAnimated()

  This property holds whether animations are enabled. If this property is true the treeview will animate expandsion and collasping of branches. If this property is false, the treeview will expand or collapse branches immediately without showing the animation.

  By default, this property is false.

### isColumnHidden

    public final boolean isColumnHidden(int column)

  Returns true if the `column` is hidden; otherwise returns false.

See also:
  `hideColumn()`, and `isRowHidden()`.

### isExpanded

    public final boolean isExpanded(com.trolltech.qt.core.QModelIndex index)

  Returns true if the model item `index` is expanded; otherwise returns false.

See also:
  `expand()`, `expanded()` , and `setExpanded()`.

### isFirstColumnSpanned

    public final boolean isFirstColumnSpanned(int row,
                                              com.trolltech.qt.core.QModelIndex parent)

  Returns true if the item in first column in the given `row` of the `parent` is spanning all the columns; otherwise returns false.

See also:
  `setFirstColumnSpanned()`.

### isHeaderHidden

    public final boolean isHeaderHidden()

  This property holds whether the header is shown or not. If this property is true, the header is not shown otherwise it is. The default value is false.

See also:
  `header()`.

### isRowHidden

    public final boolean isRowHidden(int row,
                                     com.trolltech.qt.core.QModelIndex parent)

  Returns true if the item in the given `row` of the `parent` is hidden; otherwise returns false.

See also:
  `setRowHidden()`, and `isColumnHidden()`.

### isSortingEnabled

    public final boolean isSortingEnabled()

  This property holds whether sorting is enabled. If this property is true, sorting is enabled for the tree; if the property is false, sorting is not enabled. The default value is false.

  Note: In order to avoid performance issues, it is recommended that sorting is enabled after inserting the items into the tree. Alternatively, you could also insert the items into a list before inserting the items into the tree.

See also:
  `sortByColumn()`.

### itemsExpandable

    public final boolean itemsExpandable()

  This property holds whether the items are expandable by the user. This property holds whether the user can expand and collapse items interactively.

  By default, this property is true.

### resizeColumnToContents

    public final void resizeColumnToContents(int column)

  Resizes the `column` given to the size of its contents.

See also:
  `columnWidth()`, and `setColumnWidth()`.

### rootIsDecorated

    public final boolean rootIsDecorated()

  This property holds whether to show controls for expanding and collapsing top-level items. Items with children are typically shown with controls to expand and collapse them, allowing their children to be shown or hidden. If this property is false, these controls are not shown for top-level items. This can be used to make a single level tree structure appear like a simple list of items.

  By default, this property is true.

### rowHeight

    protected final int rowHeight(com.trolltech.qt.core.QModelIndex index)

  Returns the height of the row indicated by the given `index`.

See also:
  `indexRowSizeHint()`.

### rowsRemoved

    protected final void rowsRemoved(com.trolltech.qt.core.QModelIndex parent,
                                     int first,
                                     int last)

  Informs the view that the rows from the `start` row to the `end` row inclusive have been removed from the given `parent` model item.

### setAllColumnsShowFocus

    public final void setAllColumnsShowFocus(boolean enable)

  This property holds whether items should show keyboard focus using all columns. If this property is true all columns will show focus, otherwise only one column will show focus.

  The default is false.

### setAnimated

    public final void setAnimated(boolean enable)

  This property holds whether animations are enabled. If this property is true the treeview will animate expandsion and collasping of branches. If this property is false, the treeview will expand or collapse branches immediately without showing the animation.

  By default, this property is false.

### setAutoExpandDelay

    public final void setAutoExpandDelay(int delay)

  This property holds The delay time before items in a tree are opened during a drag and drop operation. This property holds the amount of time in milliseconds that the user must wait over a node before that node will automatically open or close. If the time is set to less then 0 then it will not be activated.

  By default, this property has a value of -1, meaning that auto-expansion is disabled.

### setColumnHidden

    public final void setColumnHidden(int column,
                                      boolean hide)

  If `hide` is true the `column` is hidden, otherwise the `column` is shown.

See also:
  `isColumnHidden()`, `hideColumn()`, and `setRowHidden()`.

### setColumnWidth

    public final void setColumnWidth(int column,
                                     int width)

  Sets the width of the given `column` to the `width` specified.

See also:
  `columnWidth()`, and `resizeColumnToContents()`.

### setExpanded

    public final void setExpanded(com.trolltech.qt.core.QModelIndex index,
                                  boolean expand)

  Sets the item referred to by `index` to either collapse or expanded, depending on the value of `expanded`.

See also:
  `expanded()` , `expand()`, and `isExpanded()`.

### setExpandsOnDoubleClick

    public final void setExpandsOnDoubleClick(boolean enable)

  This property holds whether the items can be expanded by double-clicking. This property holds whether the user can expand and collapse items by double-clicking. The default value is true.

See also:
  `itemsExpandable`.

### setFirstColumnSpanned

    public final void setFirstColumnSpanned(int row,
                                            com.trolltech.qt.core.QModelIndex parent,
                                            boolean span)

  If `span` is true the item in the first column in the `row` with the given `parent` is set to span all columns, otherwise all items on the `row` are shown.

See also:
  `isFirstColumnSpanned()`.

### setHeader

    public final void setHeader(QHeaderView header)

  Sets the header for the tree view, to the given `header`.

  The view takes ownership over the given `header` and deletes it when a new header is set.

See also:
  `QAbstractItemModel::headerData()`.

### setHeaderHidden

    public final void setHeaderHidden(boolean hide)

  This property holds whether the header is shown or not. If this property is true, the header is not shown otherwise it is. The default value is false.

See also:
  `header()`.

### setIndentation

    public final void setIndentation(int i)

  This property holds indentation of the items in the tree view. This property holds the indentation measured in pixels of the items for each level in the tree view. For top-level items, the indentation specifies the horizontal distance from the viewport edge to the items in the first column; for child items, it specifies their indentation from their parent items.

  By default, this property has a value of 20.

### setItemsExpandable

    public final void setItemsExpandable(boolean enable)

  This property holds whether the items are expandable by the user. This property holds whether the user can expand and collapse items interactively.

  By default, this property is true.

### setRootIsDecorated

    public final void setRootIsDecorated(boolean show)

  This property holds whether to show controls for expanding and collapsing top-level items. Items with children are typically shown with controls to expand and collapse them, allowing their children to be shown or hidden. If this property is false, these controls are not shown for top-level items. This can be used to make a single level tree structure appear like a simple list of items.

  By default, this property is true.

### setRowHidden

    public final void setRowHidden(int row,
                                   com.trolltech.qt.core.QModelIndex parent,
                                   boolean hide)

  If `hide` is true the `row` with the given `parent` is hidden, otherwise the `row` is shown.

See also:
  `isRowHidden()`, and `setColumnHidden()`.

### setSortingEnabled

    public final void setSortingEnabled(boolean enable)

  This property holds whether sorting is enabled. If this property is true, sorting is enabled for the tree; if the property is false, sorting is not enabled. The default value is false.

  Note: In order to avoid performance issues, it is recommended that sorting is enabled after inserting the items into the tree. Alternatively, you could also insert the items into a list before inserting the items into the tree.

See also:
  `sortByColumn()`.

### setUniformRowHeights

    public final void setUniformRowHeights(boolean uniform)

  This property holds whether all items in the treeview have the same height. This property should only be set to true if it is guaranteed that all items in the view has the same height. This enables the view to do some optimizations.

  The height is obtained from the first item in the view. It is updated when the data changes on that item.

  By default, this property is false.

### setWordWrap

    public final void setWordWrap(boolean on)

  This property holds the item text word-wrapping policy. If this property is true then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is false by default.

  Note that even if wrapping is enabled, the cell will not be expanded to fit all text. Ellipsis will be inserted according to the current `textElideMode`.

### showColumn

    public final void showColumn(int column)

  Shows the given `column` in the tree view.

See also:
  `hideColumn()`, and `setColumnHidden()`.

### sortByColumn

    public final void sortByColumn(int column,
                                   Qt.SortOrder order)

  Sets the model up for sorting by the values in the given `column` and `order`.

See also:
  `sortingEnabled`.

### uniformRowHeights

    public final boolean uniformRowHeights()

  This property holds whether all items in the treeview have the same height. This property should only be set to true if it is guaranteed that all items in the view has the same height. This enables the view to do some optimizations.

  The height is obtained from the first item in the view. It is updated when the data changes on that item.

  By default, this property is false.

### wordWrap

    public final boolean wordWrap()

  This property holds the item text word-wrapping policy. If this property is true then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is false by default.

  Note that even if wrapping is enabled, the cell will not be expanded to fit all text. Ellipsis will be inserted according to the current `textElideMode`.

### drawBranches

    protected void drawBranches(QPainter painter,
                                QRect rect,
                                com.trolltech.qt.core.QModelIndex index)

  Draws the branches in the tree view on the same row as the model item `index`, using the `painter` given. The branches are drawn in the rectangle specified by `rect`.

### drawRow

    protected void drawRow(QPainter painter,
                           QStyleOptionViewItem options,
                           com.trolltech.qt.core.QModelIndex index)

  Draws the row in the tree view that contains the model item `index`, using the `painter` given. The `option` control how the item is displayed.

See also:
  setAlternatingRowColors().

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD