Member Function Documentation
QTreeView::QTreeView(parent = nullptr)
Constructs a tree view with a parent to represent a model's data. Use setModel() to set the model.
[slot]void QTreeView::collapse(const index)
Collapses the model item specified by the index.
See alsocollapsed().
[slot]void QTreeView::collapseAll()
Collapses all expanded items.
This function was introduced in Qt 4.2.
[signal]void QTreeView::collapsed(const index)
This signal is emitted when the item specified by index is collapsed.
[protected slot]void QTreeView::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 slot]void QTreeView::columnMoved()
This slot is called whenever a column has been moved.
[protected slot]void QTreeView::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.
[slot]void QTreeView::expand(const index)
Expands the model item specified by the index.
See alsoexpanded().
[slot]void QTreeView::expandAll()
Expands all expandable items.
Warning: : if the model contains a large number of items, this function will take some time to execute.
This function was introduced in Qt 4.2.
[slot]void QTreeView::expandRecursively(const index, int depth = -1)
Expands the item at the given index and all its children to the given depth. The depth is relative to the given index. A depth of -1 will expand all children, a depth of 0 will only expand the given index.
Warning: : if the model contains a large number of items, this function will take some time to execute.
This function was introduced in Qt 5.13.
See alsoexpandAll().
[slot]void QTreeView::expandToDepth(int depth)
Expands all expandable items to the given depth.
This function was introduced in Qt 4.3.
[signal]void QTreeView::expanded(const index)
This signal is emitted when the item specified by index is expanded.
See alsosetExpanded().
[slot]void QTreeView::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.
[slot]void QTreeView::resizeColumnToContents(int column)
Resizes the column given to the size of its contents.
[protected slot]void QTreeView::rowsRemoved(const parent, int start, int end)
Informs the view that the rows from the start row to the end row inclusive have been removed from the given parent model item.
This function was introduced in Qt 4.1.
[slot]void QTreeView::showColumn(int column)
Shows the given column in the tree view.
[slot]void QTreeView::sortByColumn(int column, order)
Sorts the model by the values in the given column and order.
column 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.
This function was introduced in Qt 4.2.
[virtual]QTreeView::~QTreeView()
Destroys the tree view.
int QTreeView::columnAt(int x) const
Returns the column in the tree view whose header covers the x coordinate given.
int QTreeView::columnViewportPosition(int column) const
Returns the horizontal position of the column in the viewport.
int QTreeView::columnWidth(int column) const
Returns the width of the column.
[override virtual protected]void QTreeView::currentChanged(const current, const previous)
Reimplements: QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous).
[override virtual]void QTreeView::dataChanged(const topLeft, const bottomRight, const int> &roles = QVector())
Reimplements: QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles).
[override virtual protected]void QTreeView::dragMoveEvent(event)
Reimplements: QAbstractItemView::dragMoveEvent(QDragMoveEvent *event).
[virtual protected]void QTreeView::drawBranches(painter, const rect, const index) const
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.
[virtual protected]void QTreeView::drawRow(painter, const option, const index) const
Draws the row in the tree view that contains the model item index, using the painter given. The option controls how the item is displayed.
[protected]void QTreeView::drawTree(painter, const region) const
Draws the part of the tree intersecting the given region using the specified painter.
This function was introduced in Qt 4.2.
See alsopaintEvent().
header() const
Returns the header for the tree view.
[override virtual protected]int QTreeView::horizontalOffset() const
Returns the horizontal offset of the items in the treeview.
Note that the tree view uses the horizontal header section positions to determine the positions of columns in the view.
indexAbove(const index) const
Returns the model index of the item above index.
[override virtual]indexAt(const point) const
Reimplements: QAbstractItemView::indexAt(const QPoint &point) const.
indexBelow(const index) const
Returns the model index of the item below index.
[protected]int QTreeView::indexRowSizeHint(const index) const
Returns the size hint for the row indicated by index.
bool QTreeView::isColumnHidden(int column) const
Returns true if the column is hidden; otherwise returns false.
bool QTreeView::isExpanded(const index) const
Returns true if the model item index is expanded; otherwise returns false.
bool QTreeView::isFirstColumnSpanned(int row, const parent) const
Returns true if the item in first column in the given row of the parent is spanning all the columns; otherwise returns false.
This function was introduced in Qt 4.3.
[override virtual protected]bool QTreeView::isIndexHidden(const index) const
Reimplements: QAbstractItemView::isIndexHidden(const QModelIndex &index) const.
bool QTreeView::isRowHidden(int row, const parent) const
Returns true if the item in the given row of the parent is hidden; otherwise returns false.
[override virtual protected]void QTreeView::keyPressEvent(event)
Reimplements: QAbstractItemView::keyPressEvent(QKeyEvent *event).
[override virtual]void QTreeView::keyboardSearch(const search)
Reimplements: QAbstractItemView::keyboardSearch(const QString &search).
[override virtual protected]void QTreeView::mouseDoubleClickEvent(event)
[override virtual protected]void QTreeView::mouseMoveEvent(event)
Reimplements: QAbstractItemView::mouseMoveEvent(QMouseEvent *event).
[override virtual protected]void QTreeView::mousePressEvent(event)
Reimplements: QAbstractItemView::mousePressEvent(QMouseEvent *event).
[override virtual protected]void QTreeView::mouseReleaseEvent(event)
[override virtual protected]moveCursor(cursorAction, modifiers)
Reimplements: QAbstractItemView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers).
Move the cursor in the way described by cursorAction, using the information provided by the button modifiers.
[override virtual protected]void QTreeView::paintEvent(event)
Reimplements: QAbstractScrollArea::paintEvent(QPaintEvent *event).
[override virtual]void QTreeView::reset()
[protected]int QTreeView::rowHeight(const index) const
Returns the height of the row indicated by the given index.
This function was introduced in Qt 4.3.
[override virtual protected]void QTreeView::rowsAboutToBeRemoved(const parent, int start, int end)
Reimplements: QAbstractItemView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end).
Informs the view that the rows from the start row to the end row inclusive are about to removed from the given parent model item.
[override virtual protected]void QTreeView::rowsInserted(const parent, int start, int end)
Reimplements: QAbstractItemView::rowsInserted(const QModelIndex &parent, int start, int end).
Informs the view that the rows from the start row to the end row inclusive have been inserted into the parent model item.
[override virtual protected]void QTreeView::scrollContentsBy(int dx, int dy)
Scrolls the contents of the tree view by (dx, dy).
[override virtual]void QTreeView::scrollTo(const index, hint = EnsureVisible)
Reimplements: QAbstractItemView::scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint).
Scroll the contents of the tree view until the given model item index is visible. The hint 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.
[override virtual]void QTreeView::selectAll()
[override virtual protected]selectedIndexes() const
[override virtual protected]void QTreeView::selectionChanged(const selected, const deselected)
Reimplements: QAbstractItemView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected).
void QTreeView::setColumnHidden(int column, bool hide)
If hide is true the column is hidden, otherwise the column is shown.
void QTreeView::setColumnWidth(int column, int width)
Sets the width of the given column to the width specified.
This function was introduced in Qt 4.2.
void QTreeView::setExpanded(const index, bool expanded)
Sets the item referred to by index to either collapse or expanded, depending on the value of expanded.
void QTreeView::setFirstColumnSpanned(int row, const parent, bool 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.
This function was introduced in Qt 4.3.
void QTreeView::setHeader(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.
[override virtual]void QTreeView::setModel(model)
Reimplements: QAbstractItemView::setModel(QAbstractItemModel *model).
[override virtual]void QTreeView::setRootIndex(const index)
Reimplements: QAbstractItemView::setRootIndex(const QModelIndex &index).
void QTreeView::setRowHidden(int row, const parent, bool hide)
If hide is true the row with the given parent is hidden, otherwise the row is shown.
[override virtual protected]void QTreeView::setSelection(const rect, command)
Reimplements: QAbstractItemView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags).
Applies the selection command to the items in or touched by the rectangle, rect.
[override virtual]void QTreeView::setSelectionModel(selectionModel)
Reimplements: QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel).
void QTreeView::setTreePosition(int index)
This specifies that the tree structure should be placed at logical index index. If set to -1 then the tree will always follow visual index 0.
This function was introduced in Qt 5.2.
[override virtual protected]int QTreeView::sizeHintForColumn(int column) const
Returns the size hint for the column's width or -1 if there is no model.
If you need to set the width of a given column to a fixed value, call QHeaderView::resizeSection() on the view's header.
If you reimplement this function in a subclass, note that the value you return is only used when resizeColumnToContents() 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.
[override virtual protected]void QTreeView::timerEvent(event)
Reimplements: QAbstractItemView::timerEvent(QTimerEvent *event).
int QTreeView::treePosition() const
Return the logical index the tree is set on. If the return value is -1 then the tree is placed on the visual index 0.
This function was introduced in Qt 5.2.
[override virtual protected]void QTreeView::updateGeometries()
[override virtual protected]int QTreeView::verticalOffset() const
Returns the vertical offset of the items in the tree view.
[override virtual protected]bool QTreeView::viewportEvent(event)
[override virtual protected]viewportSizeHint() const
[override virtual]visualRect(const index) const
Reimplements: QAbstractItemView::visualRect(const QModelIndex &index) const.
Returns the rectangle on the viewport occupied by the item at index. If the index is not visible or explicitly hidden, the returned rectangle is invalid.
[override virtual protected]visualRegionForSelection(const selection) const
Reimplements: QAbstractItemView::visualRegionForSelection(const QItemSelection &selection) const.
Returns the rectangle from the viewport of the items in the given selection.
Since 4.7, the returned region only contains rectangles intersecting (or included in) the viewport.