CopperSpice API  1.9.1
QTreeView Class Reference

The QTreeView class provides a model/view implementation of a tree view. More...

Inheritance diagram for QTreeView:
QAbstractItemView QAbstractScrollArea QFrame QWidget QObject QPaintDevice QTreeWidget

Public Signals

void collapsed (const QModelIndex &index)
 
void expanded (const QModelIndex &index)
 
- Public Signals inherited from QAbstractItemView
void activated (const QModelIndex &index)
 
void clicked (const QModelIndex &index)
 
void doubleClicked (const QModelIndex &index)
 
void entered (const QModelIndex &index)
 
void iconSizeChanged (const QSize &size)
 
void pressed (const QModelIndex &index)
 
void viewportEntered ()
 
- Public Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 
void windowIconChanged (const QIcon &icon)
 
void windowIconTextChanged (const QString &iconText)
 
void windowTitleChanged (const QString &title)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void collapse (const QModelIndex &index)
 
void collapseAll ()
 
void expand (const QModelIndex &index)
 
void expandAll ()
 
void expandToDepth (int depth)
 
void hideColumn (int column)
 
void resizeColumnToContents (int column)
 
void showColumn (int column)
 
void sortByColumn (int column)
 
- Public Slots inherited from QAbstractItemView
void clearSelection ()
 
void edit (const QModelIndex &index)
 
virtual void reset ()
 
void scrollToBottom ()
 
void scrollToTop ()
 
virtual void selectAll ()
 
void setCurrentIndex (const QModelIndex &index)
 
virtual void setRootIndex (const QModelIndex &index)
 
void update (const QModelIndex &index)
 
- Public Slots inherited from QWidget
bool close ()
 
void hide ()
 
void lower ()
 
void raise ()
 
void repaint ()
 
void setDisabled (bool disable)
 
void setEnabled (bool enable)
 
void setFocus ()
 
void setHidden (bool hidden)
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool modified)
 
void setWindowTitle (const QString &title)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
void update ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QTreeView (QWidget *parent=nullptr)
 
 ~QTreeView ()
 
bool allColumnsShowFocus () const
 
int autoExpandDelay () const
 
int columnAt (int x) const
 
int columnViewportPosition (int column) const
 
int columnWidth (int column) const
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >()) override
 
bool expandsOnDoubleClick () const
 
QHeaderViewheader () const
 
int indentation () const
 
QModelIndex indexAbove (const QModelIndex &index) const
 
QModelIndex indexAt (const QPoint &point) const override
 
QModelIndex indexBelow (const QModelIndex &index) const
 
bool isAnimated () const
 
bool isColumnHidden (int column) const
 
bool isExpanded (const QModelIndex &index) const
 
bool isFirstColumnSpanned (int row, const QModelIndex &parent) const
 
bool isHeaderHidden () const
 
bool isRowHidden (int row, const QModelIndex &parent) const
 
bool isSortingEnabled () const
 
bool itemsExpandable () const
 
void keyboardSearch (const QString &search) override
 
void reset () override
 
void resetIndentation ()
 
bool rootIsDecorated () const
 
void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible) override
 
void selectAll () override
 
void setAllColumnsShowFocus (bool enable)
 
void setAnimated (bool enable)
 
void setAutoExpandDelay (int delay)
 
void setColumnHidden (int column, bool hide)
 
void setColumnWidth (int column, int width)
 
void setExpanded (const QModelIndex &index, bool expanded)
 
void setExpandsOnDoubleClick (bool enable)
 
void setFirstColumnSpanned (int row, const QModelIndex &parent, bool span)
 
void setHeader (QHeaderView *header)
 
void setHeaderHidden (bool hide)
 
void setIndentation (int i)
 
void setItemsExpandable (bool enable)
 
void setModel (QAbstractItemModel *model) override
 
void setRootIndex (const QModelIndex &index) override
 
void setRootIsDecorated (bool show)
 
void setRowHidden (int row, const QModelIndex &parent, bool hide)
 
void setSelectionModel (QItemSelectionModel *selectionModel) override
 
void setSortingEnabled (bool enable)
 
void setTreePosition (int logicalIndex)
 
void setUniformRowHeights (bool uniform)
 
void setWordWrap (bool on)
 
void sortByColumn (int column, Qt::SortOrder order)
 
int treePosition () const
 
bool uniformRowHeights () const
 
QRect visualRect (const QModelIndex &index) const override
 
bool wordWrap () const
 
- Public Methods inherited from QAbstractItemView
 QAbstractItemView (QWidget *parent=nullptr)
 
 ~QAbstractItemView ()
 
bool alternatingRowColors () const
 
int autoScrollMargin () const
 
void closePersistentEditor (const QModelIndex &index)
 
QModelIndex currentIndex () const
 
Qt::DropAction defaultDropAction () const
 
DragDropMode dragDropMode () const
 
bool dragDropOverwriteMode () const
 
bool dragEnabled () const
 
EditTriggers editTriggers () const
 
bool hasAutoScroll () const
 
ScrollMode horizontalScrollMode () const
 
QSize iconSize () const
 
QWidgetindexWidget (const QModelIndex &index) const
 
QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 
QAbstractItemDelegateitemDelegate () const
 
QAbstractItemDelegateitemDelegate (const QModelIndex &index) const
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 
QAbstractItemModelmodel () const
 
void openPersistentEditor (const QModelIndex &index)
 
QModelIndex rootIndex () const
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QAbstractItemView::SelectionMode selectionMode () const
 
QItemSelectionModelselectionModel () const
 
void setAlternatingRowColors (bool enable)
 
void setAutoScroll (bool enable)
 
void setAutoScrollMargin (int margin)
 
void setDefaultDropAction (Qt::DropAction dropAction)
 
void setDragDropMode (DragDropMode behavior)
 
void setDragDropOverwriteMode (bool overwrite)
 
void setDragEnabled (bool enable)
 
void setDropIndicatorShown (bool enable)
 
void setEditTriggers (EditTriggers triggers)
 
void setHorizontalScrollMode (ScrollMode mode)
 
void setIconSize (const QSize &size)
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
void setTabKeyNavigation (bool enable)
 
void setTextElideMode (Qt::TextElideMode mode)
 
void setVerticalScrollMode (ScrollMode mode)
 
bool showDropIndicator () const
 
QSize sizeHintForIndex (const QModelIndex &index) const
 
virtual int sizeHintForRow (int row) const
 
bool tabKeyNavigation () const
 
Qt::TextElideMode textElideMode () const
 
ScrollMode verticalScrollMode () const
 
- Public Methods inherited from QAbstractScrollArea
 QAbstractScrollArea (QWidget *parent=nullptr)
 
 ~QAbstractScrollArea ()
 
void addScrollBarWidget (QWidget *widget, Qt::Alignment alignment)
 
QWidgetcornerWidget () const
 
QScrollBarhorizontalScrollBar () const
 
Qt::ScrollBarPolicy horizontalScrollBarPolicy () const
 
QSize maximumViewportSize () const
 
QSize minimumSizeHint () const override
 
QWidgetList scrollBarWidgets (Qt::Alignment alignment)
 
void setCornerWidget (QWidget *widget)
 
void setHorizontalScrollBar (QScrollBar *scrollBar)
 
void setHorizontalScrollBarPolicy (Qt::ScrollBarPolicy policy)
 
void setSizeAdjustPolicy (SizeAdjustPolicy policy)
 
virtual void setupViewport (QWidget *viewport)
 
void setVerticalScrollBar (QScrollBar *scrollBar)
 
void setVerticalScrollBarPolicy (Qt::ScrollBarPolicy policy)
 
void setViewport (QWidget *widget)
 
SizeAdjustPolicy sizeAdjustPolicy () const
 
QSize sizeHint () const override
 
QScrollBarverticalScrollBar () const
 
Qt::ScrollBarPolicy verticalScrollBarPolicy () const
 
QWidgetviewport () const
 
- Public Methods inherited from QFrame
 QFrame (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QFrame ()
 
QRect frameRect () const
 
Shadow frameShadow () const
 
Shape frameShape () const
 
int frameStyle () const
 
int frameWidth () const
 
int lineWidth () const
 
int midLineWidth () const
 
void setFrameRect (const QRect &rect)
 
void setFrameShadow (Shadow value)
 
void setFrameShape (Shape value)
 
void setFrameStyle (int style)
 
void setLineWidth (int width)
 
void setMidLineWidth (int width)
 
QSize sizeHint () const override
 
- Public Methods inherited from QWidget
 QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QWidget ()
 
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void adjustSize ()
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 
QBackingStorebackingStore () const
 
QSize baseSize () const
 
QWidget * childAt (const QPoint &position) const
 
QWidget * childAt (int x, int y) const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 
void clearMask ()
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
QCursor cursor () const
 
WId effectiveWinId () const
 
void ensurePolished () const
 
Qt::FocusPolicy focusPolicy () const
 
QWidget * focusProxy () const
 
QWidget * focusWidget () const
 
const QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
QPixmap grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1)))
 
void grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ())
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 
bool hasEditFocus () const
 
bool hasFocus () const
 
virtual bool hasHeightForWidth () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int width) const
 
Qt::InputMethodHints inputMethodHints () const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *parent) const
 
bool isEnabledToTLW () const
 
bool isFullScreen () const
 
bool isHidden () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isTopLevel () const
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *parent) const
 
bool isWindow () const
 
bool isWindowModified () const
 
QLayoutlayout () const
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapFromParent (const QPoint &pos) const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QPoint mapToParent (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (const QPoint &point)
 
void move (int x, int y)
 
QWidget * nativeParentWidget () const
 
QWidget * nextInFocusChain () const
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
QPaintEnginepaintEngine () const override
 
const QPalettepalette () const
 
QWidget * parentWidget () const
 
QPoint pos () const
 
QWidget * previousInFocusChain () const
 
QRect rect () const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &region)
 
void repaint (int x, int y, int w, int h)
 
void resize (const QSize &size)
 
void resize (int w, int h)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &rect)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool enable=true)
 
void setAutoFillBackground (bool enable)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (const QSize &size)
 
void setBaseSize (int basew, int baseh)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &cursor)
 
void setEditFocus (bool enable)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &size)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *widget)
 
void setFont (const QFont &font)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &rect)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &palette)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags flags)
 
void setShortcutAutoRepeat (int id, bool enable=true)
 
void setShortcutEnabled (int id, bool enable=true)
 
void setSizeIncrement (const QSize &size)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy policy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &data)
 
void setStyle (QStyle *style)
 
void setToolTip (const QString &data)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setWhatsThis (const QString &str)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags flags)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *widget)
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
QString toolTip () const
 
int toolTipDuration () const
 
QWidget * topLevelWidget () const
 
bool underMouse () const
 
void ungrabGesture (Qt::GestureType gestureType)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (const QRect &rect)
 
void update (const QRegion &region)
 
void update (int x, int y, int w, int h)
 
void updateGeometry ()
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 
QString whatsThis () const
 
int width () const
 
QWidget * window () const
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 
QWindowwindowHandle () const
 
QIcon windowIcon () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 
Qt::WindowStates windowState () const
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 
WId winId () const
 
int x () const
 
int y () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Protected Slots

void columnCountChanged (int oldCount, int newCount)
 
void columnMoved ()
 
void columnResized (int column, int oldSize, int newSize)
 
void rowsRemoved (const QModelIndex &parent, int start, int end)
 
- Protected Slots inherited from QAbstractItemView
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 
virtual void commitData (QWidget *editor)
 
virtual void currentChanged (const QModelIndex &current, const QModelIndex &previous)
 
virtual void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >())
 
virtual void editorDestroyed (QObject *editor)
 
virtual void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
virtual void rowsInserted (const QModelIndex &parent, int start, int end)
 
virtual void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 
virtual void updateGeometries ()
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 

Protected Methods

void currentChanged (const QModelIndex &current, const QModelIndex &previous) override
 
void dragMoveEvent (QDragMoveEvent *event) override
 
virtual void drawBranches (QPainter *painter, const QRect &rect, const QModelIndex &index) const
 
virtual void drawRow (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
 
void drawTree (QPainter *painter, const QRegion &region) const
 
int horizontalOffset () const override
 
void horizontalScrollbarAction (int action) override
 
int indexRowSizeHint (const QModelIndex &index) const
 
bool isIndexHidden (const QModelIndex &index) const override
 
void keyPressEvent (QKeyEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
QModelIndex moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
 
void paintEvent (QPaintEvent *event) override
 
int rowHeight (const QModelIndex &index) const
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) override
 
void rowsInserted (const QModelIndex &parent, int start, int end) override
 
void scrollContentsBy (int dx, int dy) override
 
QModelIndexList selectedIndexes () const override
 
void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override
 
void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command) override
 
int sizeHintForColumn (int column) const override
 
void timerEvent (QTimerEvent *event) override
 
void updateGeometries () override
 
int verticalOffset () const override
 
bool viewportEvent (QEvent *event) override
 
QSize viewportSizeHint () const override
 
QRegion visualRegionForSelection (const QItemSelection &selection) const override
 
- Protected Methods inherited from QAbstractItemView
QPoint dirtyRegionOffset () const
 
void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
DropIndicatorPosition dropIndicatorPosition () const
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 
bool event (QEvent *event) override
 
void executeDelayedItemsLayout ()
 
void focusInEvent (QFocusEvent *event) override
 
bool focusNextPrevChild (bool next) override
 
void focusOutEvent (QFocusEvent *event) override
 
int horizontalStepsPerItem () const
 
void inputMethodEvent (QInputMethodEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void scheduleDelayedItemsLayout ()
 
void scrollDirtyRegion (int dx, int dy)
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 
void setDirtyRegion (const QRegion &region)
 
void setHorizontalStepsPerItem (int steps)
 
void setState (State state)
 
void setVerticalStepsPerItem (int steps)
 
virtual void startDrag (Qt::DropActions supportedActions)
 
State state () const
 
void timerEvent (QTimerEvent *event) override
 
int verticalStepsPerItem () const
 
virtual QStyleOptionViewItem viewOptions () const
 
- Protected Methods inherited from QAbstractScrollArea
void contextMenuEvent (QContextMenuEvent *event) override
 
void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dragMoveEvent (QDragMoveEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
bool event (QEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void setViewportMargins (const QMargins &margins)
 
void setViewportMargins (int left, int top, int right, int bottom)
 
QMargins viewportMargins () const
 
void wheelEvent (QWheelEvent *event) override
 
- Protected Methods inherited from QFrame
void changeEvent (QEvent *event) override
 
void drawFrame (QPainter *painter)
 
bool event (QEvent *event) override
 
void initStyleOption (QStyleOptionFrame *option) const
 
void paintEvent (QPaintEvent *event) override
 
- Protected Methods inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
void create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
virtual void enterEvent (QEvent *event)
 
bool event (QEvent *event) override
 
bool focusNextChild ()
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
void initPainter (QPainter *painter) const override
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
int metric (PaintDeviceMetric metric) const override
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Properties

 allColumnsShowFocus
 
 animated
 
 autoExpandDelay
 
 expandsOnDoubleClick
 
 headerHidden
 
 indentation
 
 itemsExpandable
 
 rootIsDecorated
 
 sortingEnabled
 
 uniformRowHeights
 
 wordWrap
 
- Properties inherited from QAbstractItemView
 alternatingRowColors
 
 autoScroll
 
 autoScrollMargin
 
 defaultDropAction
 
 dragDropMode
 
 dragDropOverwriteMode
 
 dragEnabled
 
 editTriggers
 
 horizontalScrollMode
 
 iconSize
 
 selectionBehavior
 
 selectionMode
 
 showDropIndicator
 
 tabKeyNavigation
 
 textElideMode
 
 verticalScrollMode
 
- Properties inherited from QAbstractScrollArea
 horizontalScrollBarPolicy
 
 verticalScrollBarPolicy
 
- Properties inherited from QFrame
 frameRect
 
 frameShadow
 
 frameShape
 
 frameWidth
 
 lineWidth
 
 midLineWidth
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Typedefs inherited from QAbstractItemView
using EditTriggers = QFlags< EditTrigger >
 
- Public Typedefs inherited from QWidget
using RenderFlags = QFlags< RenderFlag >
 
- Public Types inherited from QAbstractItemView
enum  DragDropMode
 
enum  EditTrigger
 
enum  ScrollHint
 
enum  ScrollMode
 
enum  SelectionBehavior
 
enum  SelectionMode
 
- Public Types inherited from QFrame
enum  Shadow
 
enum  Shape
 
enum  StyleMask
 
- Public Types inherited from QWidget
enum  RenderFlag
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 
- Static Public Methods inherited from QWidget
static QWidget * createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
static QWidget * find (WId id)
 
static QWidget * keyboardGrabber ()
 
static QWidget * mouseGrabber ()
 
static void setTabOrder (QWidget *firstWidget, QWidget *secondWidget)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Types inherited from QAbstractItemView
enum  CursorAction
 
enum  DropIndicatorPosition
 
enum  State
 

Detailed Description

The QTreeView class provides a model/view implementation of a tree view. This class can only access data which is stored in a model class. The model/view architecture ensures the contents of the tree view are updated as the model changes.

Items which have children can be expanded or collapsed and the children will become visible and hidden respectively. When this state changes a collapsed() or expanded() signal is emitted. The signal will pass the model index of the item which changed state.

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

The horizontal header displayed at the top of a tree view can be configured by calling the header() method and then using methods from the QHeaderView class. By default the header is configured with the QHeaderView::stretchLastSection property set to true.

The QTreeView class is one of the Model/View Classes.

Example

The following is a simple example. The contents of a directory are supplied by a QFileSystemModel and then displayed using a tree view.

model->setRootPath(QDir::currentPath());
QTreeView *tree = new QTreeView(splitter);
tree->setModel(model);

Key Bindings

QTreeView supports a set of key bindings which enable the user to navigate the tree view and interact with the contents of items.

KeyAction
Up Moves the cursor to the previous row
Down Moves the cursor to the next row
Right Displays the children of the current item, expands the branch
Left Hides the children of the current item, collapses the branch
Plus Same as RightArrow
Minus Same as LeftArrow
Asterisk Expands all children of the current item
PageUp Moves the cursor up one page
PageDown Moves the cursor down one page
Home Moves the cursor to the first row
End Moves the cursor to the last row
F2 Enters an edit mode on the current item if appropriate flags are set
Escape Cancels the editing process and revert any changes

Improving Performance

It is possible to give the tree view hints about the data in the model to improve performance when displaying a large number of items. One approach is for views where the row height is equal, set the uniformRowHeights property to true.

See also
QListView, QTreeWidget, QAbstractItemModel, QAbstractItemView

Constructor & Destructor Documentation

QTreeView::QTreeView ( QWidget parent = nullptr)
explicit

Constructs a tree view with the given parent.

See also
QAbstractItemModel
QTreeView::~QTreeView ( )

Destroys the tree view.

Method Documentation

bool QTreeView::allColumnsShowFocus ( ) const

Returns the value of the property.

int QTreeView::autoExpandDelay ( ) const

Returns the value of the property.

void QTreeView::collapse ( const QModelIndex index)
slot

Collapses the model item specified by the index.

See also
collapsed()
void QTreeView::collapseAll ( )
slot

Collapses all expanded items.

See also
expandAll(), expand(), collapse(), setExpanded()
void QTreeView::collapsed ( const QModelIndex index)
signal

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

int QTreeView::columnAt ( int  x) const

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

void QTreeView::columnCountChanged ( int  oldCount,
int  newCount 
)
protectedslot

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

void QTreeView::columnMoved ( )
protectedslot

This slot is called after a column is moved.

void QTreeView::columnResized ( int  column,
int  oldSize,
int  newSize 
)
protectedslot

This method is called when the size of column is changed in the header. The oldSize and newSize are in pixels.

See also
setColumnWidth()
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.

See also
resizeColumnToContents(), setColumnWidth()
void QTreeView::currentChanged ( const QModelIndex current,
const QModelIndex previous 
)
overrideprotected
void QTreeView::dataChanged ( const QModelIndex topLeft,
const QModelIndex bottomRight,
const QVector< int > &  roles = QVector<int>() 
)
override
void QTreeView::dragMoveEvent ( QDragMoveEvent event)
overrideprotectedvirtual
void QTreeView::drawBranches ( QPainter painter,
const QRect rect,
const QModelIndex index 
) const
protectedvirtual

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.

void QTreeView::drawRow ( QPainter painter,
const QStyleOptionViewItem option,
const QModelIndex index 
) const
protectedvirtual

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.

See also
setAlternatingRowColors()
void QTreeView::drawTree ( QPainter painter,
const QRegion region 
) const
protected

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

See also
paintEvent()
void QTreeView::expand ( const QModelIndex index)
slot

Expands the model item specified by the index.

See also
expanded()
void QTreeView::expandAll ( )
slot

Expands all expandable items.

See also
collapseAll(), expand(), collapse(), setExpanded()
void QTreeView::expanded ( const QModelIndex index)
signal

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

See also
setExpanded()
bool QTreeView::expandsOnDoubleClick ( ) const

Returns the value of the property.

void QTreeView::expandToDepth ( int  depth)
slot

Expands all expandable items to the given depth.

See also
expandAll(), collapseAll(), expand(), collapse(), setExpanded()
QHeaderView * QTreeView::header ( ) const

Returns the header for the tree view.

See also
setHeader(), QAbstractItemModel::headerData()
void QTreeView::hideColumn ( int  column)
slot

Hides the given column. This method should only be called after the model has been initialized since the view needs to know the number of columns.

See also
showColumn(), setColumnHidden()
int QTreeView::horizontalOffset ( ) const
overrideprotectedvirtual

Returns the horizontal offset of the items in the tree view. The tree view uses the horizontal header section positions to determine the positions of columns in the view.

See also
verticalOffset()

Implements QAbstractItemView::horizontalOffset()

void QTreeView::horizontalScrollbarAction ( int  action)
overrideprotected

Returns the value of the property.

int QTreeView::indentation ( ) const

Returns the value of the property.

QModelIndex QTreeView::indexAbove ( const QModelIndex index) const

Returns the model index of the item above index.

QModelIndex QTreeView::indexAt ( const QPoint point) const
overridevirtual
QModelIndex QTreeView::indexBelow ( const QModelIndex index) const

Returns the model index of the item below index.

int QTreeView::indexRowSizeHint ( const QModelIndex index) const
protected

Returns the size hint for the row indicated by index.

See also
sizeHintForColumn(), uniformRowHeights()
bool QTreeView::isAnimated ( ) const

Returns the value of the property.

bool QTreeView::isColumnHidden ( int  column) const

Returns true if the column is hidden, otherwise returns false.

See also
hideColumn(), isRowHidden()
bool QTreeView::isExpanded ( const QModelIndex index) const

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

See also
expand(), expanded(), setExpanded()
bool QTreeView::isFirstColumnSpanned ( int  row,
const QModelIndex 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.

See also
setFirstColumnSpanned()
bool QTreeView::isHeaderHidden ( ) const

Returns the value of the property.

bool QTreeView::isIndexHidden ( const QModelIndex index) const
overrideprotectedvirtual
bool QTreeView::isRowHidden ( int  row,
const QModelIndex parent 
) const

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

See also
setRowHidden(), isColumnHidden()
bool QTreeView::isSortingEnabled ( ) const

Returns the value of the property.

bool QTreeView::itemsExpandable ( ) const

Returns the value of the property.

void QTreeView::keyboardSearch ( const QString search)
overridevirtual
void QTreeView::keyPressEvent ( QKeyEvent event)
overrideprotectedvirtual
void QTreeView::mouseDoubleClickEvent ( QMouseEvent event)
overrideprotectedvirtual
void QTreeView::mouseMoveEvent ( QMouseEvent event)
overrideprotectedvirtual
void QTreeView::mousePressEvent ( QMouseEvent event)
overrideprotectedvirtual
void QTreeView::mouseReleaseEvent ( QMouseEvent event)
overrideprotectedvirtual
QModelIndex QTreeView::moveCursor ( CursorAction  cursorAction,
Qt::KeyboardModifiers  modifiers 
)
overrideprotectedvirtual

Move the cursor in the way described by cursorAction, using the information provided by the button modifiers.

Implements QAbstractItemView::moveCursor()

void QTreeView::paintEvent ( QPaintEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::paintEvent()

void QTreeView::reset ( )
override

Reimplemented from QAbstractItemView::reset()

void QTreeView::resetIndentation ( )

Resets the value of the property to the default, which is style dependent.

void QTreeView::resizeColumnToContents ( int  column)
slot

Resizes the given column to the size of its contents.

See also
columnWidth(), setColumnWidth()
bool QTreeView::rootIsDecorated ( ) const

Returns the value of the property.

int QTreeView::rowHeight ( const QModelIndex index) const
protected

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

See also
indexRowSizeHint()
void QTreeView::rowsAboutToBeRemoved ( const QModelIndex parent,
int  start,
int  end 
)
overrideprotected

Informs the view that the rows from the start row to the end row inclusive are about to be removed from the given parent model item.

void QTreeView::rowsInserted ( const QModelIndex parent,
int  start,
int  end 
)
overrideprotected

Informs the view that the rows from the start row to the end row inclusive have been inserted into the parent model item.

void QTreeView::rowsRemoved ( const QModelIndex parent,
int  start,
int  end 
)
protectedslot

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 QTreeView::scrollContentsBy ( int  dx,
int  dy 
)
overrideprotectedvirtual

Scrolls the contents of the tree view by (dx, dy).

Reimplemented from QAbstractScrollArea::scrollContentsBy()

void QTreeView::scrollTo ( const QModelIndex index,
ScrollHint  hint = EnsureVisible 
)
overridevirtual

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.

Implements QAbstractItemView::scrollTo()

void QTreeView::selectAll ( )
override

Reimplemented from QAbstractItemView::selectAll()

QModelIndexList QTreeView::selectedIndexes ( ) const
overrideprotectedvirtual
void QTreeView::selectionChanged ( const QItemSelection selected,
const QItemSelection deselected 
)
overrideprotected
void QTreeView::setAllColumnsShowFocus ( bool  enable)

Sets the value of the property to enable.

void QTreeView::setAnimated ( bool  enable)

Sets the value of the property to enable.

void QTreeView::setAutoExpandDelay ( int  delay)

Sets the value of the property to delay.

void QTreeView::setColumnHidden ( int  column,
bool  hide 
)

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

See also
isColumnHidden(), hideColumn(), setRowHidden()
void QTreeView::setColumnWidth ( int  column,
int  width 
)

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

See also
columnWidth(), resizeColumnToContents()
void QTreeView::setExpanded ( const QModelIndex index,
bool  expanded 
)

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

See also
expanded(), expand(), isExpanded()
void QTreeView::setExpandsOnDoubleClick ( bool  enable)

Sets the value of the property to enable.

void QTreeView::setFirstColumnSpanned ( int  row,
const QModelIndex 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.

See also
isFirstColumnSpanned()
void QTreeView::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()
void QTreeView::setHeaderHidden ( bool  hide)

Sets the value of the property to hide.

void QTreeView::setIndentation ( int  i)

Sets the value of the property to i.

void QTreeView::setItemsExpandable ( bool  enable)

Sets the value of the property to enable.

void QTreeView::setModel ( QAbstractItemModel model)
overridevirtual

Reimplemented from QAbstractItemView::setModel()

void QTreeView::setRootIndex ( const QModelIndex index)
override
void QTreeView::setRootIsDecorated ( bool  show)

Sets the value of the property to show.

void QTreeView::setRowHidden ( int  row,
const QModelIndex parent,
bool  hide 
)

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

See also
isRowHidden(), setColumnHidden()
void QTreeView::setSelection ( const QRect rect,
QItemSelectionModel::SelectionFlags  command 
)
overrideprotectedvirtual

Applies the selection command to the items in or touched by the given rect.

See also
selectionCommand()

Implements QAbstractItemView::setSelection()

void QTreeView::setSelectionModel ( QItemSelectionModel selectionModel)
overridevirtual
void QTreeView::setSortingEnabled ( bool  enable)

Sets the value of the property to enable.

This method calls setSortIndicatorShown(enable) and setSectionsClickable(enable). It sorts the data based on the current column. A signal/slot connection is automatically made so when the user clicks on the column heading the current column is selected and the data sorted. Clicking again in the current column will toggle the Ascending and Descending sort order.

void QTreeView::setTreePosition ( int  logicalIndex)

Sets the value of the property to logicalIndex.

void QTreeView::setUniformRowHeights ( bool  uniform)

Sets the value of the property to uniform.

void QTreeView::setWordWrap ( bool  on)

Sets the value of the property to on.

void QTreeView::showColumn ( int  column)
slot

Shows the given column in the tree view.

See also
hideColumn(), setColumnHidden()
int QTreeView::sizeHintForColumn ( int  column) const
overrideprotectedvirtual

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 method in a subclass, 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.

See also
QWidget::sizeHint, header()

Reimplemented from QAbstractItemView::sizeHintForColumn()

void QTreeView::sortByColumn ( int  column)
deprecatedslot
Deprecated:

Sorts the model by the values in the given column.

void QTreeView::sortByColumn ( int  column,
Qt::SortOrder  order 
)

Configures sorting by the values in the given column and order. The value for column may be -1 in which case no sort indicator will be shown and the model will return to its natural, unsorted order. Not all models support this operation.

See also
sortingEnabled
void QTreeView::timerEvent ( QTimerEvent event)
overrideprotected

Reimplemented from QAbstractItemView::timerEvent()

int QTreeView::treePosition ( ) const

Returns the value of the property.

bool QTreeView::uniformRowHeights ( ) const

Returns the value of the property.

void QTreeView::updateGeometries ( )
overrideprotected
int QTreeView::verticalOffset ( ) const
overrideprotectedvirtual

Returns the vertical offset of the items in the tree view.

See also
horizontalOffset()

Implements QAbstractItemView::verticalOffset()

bool QTreeView::viewportEvent ( QEvent event)
overrideprotectedvirtual
QSize QTreeView::viewportSizeHint ( ) const
overrideprotectedvirtual

Returns the value of the property.

Reimplemented from QAbstractItemView::viewportSizeHint()

QRect QTreeView::visualRect ( const QModelIndex index) const
overridevirtual

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.

Implements QAbstractItemView::visualRect()

QRegion QTreeView::visualRegionForSelection ( const QItemSelection selection) const
overrideprotectedvirtual

Returns the rectangle from the viewport of the items in the given selection. The returned region only contains rectangles intersecting (or included in) the viewport.

Implements QAbstractItemView::visualRegionForSelection()

bool QTreeView::wordWrap ( ) const

Returns the value of the property.

Property Documentation

QTreeView::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.

PropertiesClass Methods
read allColumnsShowFocus
write setAllColumnsShowFocus
QTreeView::animated

This property holds whether animations are enabled. If this property is true the tree view will animate expansion and collapsing of branches. If this property is false, the tree view will expand or collapse branches immediately without showing the animation.

By default this property is false.

PropertiesClass Methods
read isAnimated
write setAnimated
QTreeView::autoExpandDelay

This property holds the delay time before items in a tree are opened during a drag and drop operation.

This delay time is the number of milliseconds the user must hover over a tree item before the item will automatically open or close. If the time is set to less then 0 then hovering will have no effect.

The default for this property is -1 which disables auto expansion.

PropertiesClass Methods
read autoExpandDelay
write setAutoExpandDelay
QTreeView::expandsOnDoubleClick

This property holds whether the items can be expanded by double clicking.

The default value is true.

See also
itemsExpandable
PropertiesClass Methods
read expandsOnDoubleClick
write setExpandsOnDoubleClick
QTreeView::headerHidden

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()
PropertiesClass Methods
read isHeaderHidden
write setHeaderHidden
QTreeView::indentation

This property holds the indentation measured in pixels 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 the indentation from their parent.

By default this property has a value of 20.

PropertiesClass Methods
read indentation
write setIndentation
QTreeView::itemsExpandable

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

By default this property is true.

PropertiesClass Methods
read itemsExpandable
write setItemsExpandable
QTreeView::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.

PropertiesClass Methods
read rootIsDecorated
write setRootIsDecorated
QTreeView::sortingEnabled

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. In order to avoid performance issues it is recommended to wait until items are inserted to enable sorting.

The default value is false.

See also
sortByColumn()
PropertiesClass Methods
read isSortingEnabled
write setSortingEnabled
QTreeView::uniformRowHeights

This property holds whether all items in the tree view have the same height. The height is obtained from the first item in the view and updated when the data changes for that item. Only set this property if all rows are guaranteed to have the same height. This enables the view to layout items without loading all of the items in the model.

By default this property is false.

PropertiesClass Methods
read uniformRowHeights
write setUniformRowHeights
QTreeView::wordWrap

This property holds the item text word wrapping policy. If this property is true then the item text can be wrapped at word breaks, otherwise it is never wrapped. When wrapping is enabled the cell may still not be expanded to fit all text. An ellipsis will be inserted according to the current textElideMode.

This property is false by default.

PropertiesClass Methods
read wordWrap
write setWordWrap