Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QTreeView class provides a default model/view implementation of a tree view. More...
#include <QTreeView>
Inherits QAbstractItemView.
Inherited by QTreeWidget.
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.
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(QDir(), parent); QTreeView *tree = new QTreeView(parent); 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.
See also Model/View Programming, QAbstractItemModel, and QAbstractItemView.
This property holds indentation of the items in the tree view.
This property holds the indentation of the items for each level in the tree view.
Access functions:
See also setIndentation().
This property holds whether to show controls for opening and closing items.
This property holds whether root items are displayed with controls for opening and closing them.
Access functions:
This property holds whether all items in the treeview have the same height.
This property should only be set to true if it is guarantied that all items in the view has the same height. This enables the view to do some optimizations.
Access functions:
Constructs a table view with a parent to represent a model's data. Use setModel() to set the model.
See also QAbstractItemModel.
Destroys the tree view.
Closes the model item specified by the index.
This signal is emitted when the item specified by index is collapsed.
Returns the column in the tree view whose header covers the x coordinate given.
Informs the tree view that the number of columns in the tree view has changed from oldCount to newCount.
This slot is called whenever a column has been moved.
This column is called whenever the column size is changed in the header.
Returns the size hint for the column's width.
Reimplemented from QAbstractItemView.
See also QWidget::sizeHint.
Returns the horizontal position of the column in the viewport.
Returns the width of the column.
Lays out the items in the tree view.
Reimplemented from QAbstractItemView.
Draws the branches in the tree view on the same row as the model item index, using the painter given. Only the branches within the rectangle specified by rect are drawn.
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 QStyleOptionViewItem.
Scroll the contents of the tree view until the given model item index is visible.
Reimplemented from QAbstractItemView.
This signal is emitted when the item specified by index is expanded.
Returns the header for the tree view.
Hides the column given.
See also showColumn().
Returns the horizontal offset.
Reimplemented from QAbstractItemView.
Returns the size hint for the column's width.
See also QWidget::sizeHint.
Returns true if the column is hidden; otherwise returns false.
See also hideColumn().
Returns true if the model item index is open; otherwise returns false.
Returns true if the item in the given row of the parent is hidden; otherwise returns false.
See also setRowHidden().
Returns the model index of the item above index.
Returns the model index of the item at point (x, y).
Reimplemented from QAbstractItemView.
Returns the model index of the item below index.
Returns the rectangle on the viewport occupied by the item at index.
Reimplemented from QAbstractItemView.
Move the cursor in the way described by cursorAction, using the information provided by the button state.
Reimplemented from QAbstractItemView.
See also QAbstractItemView::CursorAction.
Opens the model item specified by the index.
Resizes the column given to the size of its contents.
Informs the view that the rows from the start row to the end row inclusive have been removed from the given parent model item.
Reimplemented from QAbstractItemView.
Informs the view that the rows from the start row to the end row inclusive have been inserted into the parent model item.
Reimplemented from QAbstractItemView.
Scrolls the contents of the tree view by (dx, dy).
Reimplemented from QViewport.
Selects all the items in the underlying model.
Reimplemented from QAbstractItemView.
Returns the rectangle from the viewport of the items in the given selection.
Reimplemented from QAbstractItemView.
If hide is true the column is hidden, otherwise the column is shown.
Sets the header for the tree view.
If hide is true the row with the given parent is hidden, otherwise the row is shown.
See also isRowHidden().
Applies the selection command to the items in or touched by the rectangle, rect.
Reimplemented from QAbstractItemView.
See also selectionCommand().
Shows the given column in the tree view.
See also hideColumn().
Returns the vertical offset of the items in the tree view.
Reimplemented from QAbstractItemView.
Copyright © 2004 Trolltech | Trademarks | Qt 4.0.0-b1 |