CopperSpice API  1.7.2
QTreeView Class Reference

The QTreeView class provides a default 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)
 
void setSizeAdjustPolicy (SizeAdjustPolicy policy)
 
virtual void setupViewport (QWidget *viewport)
 
void setVerticalScrollBar (QScrollBar *scrollBar)
 
void setVerticalScrollBarPolicy (Qt::ScrollBarPolicy)
 
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 &)
 
void setFrameShadow (Shadow)
 
void setFrameShape (Shape)
 
void setFrameStyle (int style)
 
void setLineWidth (int)
 
void setMidLineWidth (int)
 
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 &objName=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 *)
 
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 Types inherited from QAbstractItemView
enum  DragDropMode
 
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)
 
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 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, but using the more flexible approach provided by the CopperSpice 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. 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.

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

Example

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 QFileSystemModel and displayed as a tree.

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

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:

KeyAction
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.
LeftHides the children of the current item (if present) by collapsing a branch.
MinusSame as LeftArrow.
RightReveals the children of the current item (if present) by expanding a branch.
PlusSame as RightArrow.
AsteriskExpands all children of the current item (if present).
PageUpMoves the cursor up one page.
PageDownMoves 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.
Windows XP style tree view Mac OS Xstyle tree view Fusion 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, QAbstractItemModel, QAbstractItemView

Constructor & Destructor Documentation

QTreeView::QTreeView ( QWidget parent = nullptr)
explicit

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

See also
QAbstractItemModel
QTreeView::~QTreeView ( )

Destroys the tree view.

Method Documentation

bool QTreeView::allColumnsShowFocus ( ) const

Property documentation pending.

int QTreeView::autoExpandDelay ( ) const

Property documentation pending.

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 whenever a column has been moved.

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

This function is called whenever column's size is changed in the header. The oldSize and newSize give the previous size and the new size 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

Reimplemented from QAbstractItemView::dataChanged().

void QTreeView::dragMoveEvent ( QDragMoveEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::dragMoveEvent().

Reimplemented from QAbstractItemView.

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 control 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. If the model contains a large number of items, this method will take some time to execute.

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

Property documentation pending.

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, as the view needs to know the number of columns in order to hide the given column.

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

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

See also
verticalOffset()

Implements QAbstractItemView.

void QTreeView::horizontalScrollbarAction ( int  action)
overrideprotected

Property documentation pending.

int QTreeView::indentation ( ) const

Property documentation pending.

QModelIndex QTreeView::indexAbove ( const QModelIndex index) const

Returns the model index of the item above index.

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

Reimplemented from QAbstractItemView::indexAt().

Implements QAbstractItemView.

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

Property documentation pending.

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

Property documentation pending.

bool QTreeView::isIndexHidden ( const QModelIndex index) const
overrideprotectedvirtual

Reimplemented from QAbstractItemView::isIndexHidden().

Implements QAbstractItemView.

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

Property documentation pending.

bool QTreeView::itemsExpandable ( ) const

Property documentation pending.

void QTreeView::keyboardSearch ( const QString search)
overridevirtual

Reimplemented from QAbstractItemView::keyboardSearch().

Reimplemented from QAbstractItemView.

void QTreeView::keyPressEvent ( QKeyEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::keyPressEvent().

Reimplemented from QAbstractItemView.

void QTreeView::mouseDoubleClickEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mouseDoubleClickEvent().

Reimplemented from QAbstractItemView.

void QTreeView::mouseMoveEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mouseMoveEvent().

Reimplemented from QAbstractItemView.

void QTreeView::mousePressEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mousePressEvent().

Reimplemented from QAbstractItemView.

void QTreeView::mouseReleaseEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mouseReleaseEvent().

Reimplemented from QAbstractItemView.

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.

void QTreeView::paintEvent ( QPaintEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::paintEvent().

Reimplemented from QWidget.

void QTreeView::reset ( )
override

Reimplemented from QAbstractItemView::reset().

void QTreeView::resetIndentation ( )

Property documentation pending.

void QTreeView::resizeColumnToContents ( int  column)
slot

Resizes the column given to the size of its contents.

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

Property documentation pending.

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

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.

void QTreeView::selectAll ( )
override

Reimplemented from QAbstractItemView::selectAll().

QModelIndexList QTreeView::selectedIndexes ( ) const
overrideprotectedvirtual

Reimplemented from QAbstractItemView::selectedIndexes().

Reimplemented from QAbstractItemView.

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

Property documentation pending.

void QTreeView::setAnimated ( bool  enable)

Property documentation pending.

void QTreeView::setAutoExpandDelay ( int  delay)

Property documentation pending.

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 collapse or expanded, depending on the value of expanded.

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

Property documentation pending.

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)

Property documentation pending.

void QTreeView::setIndentation ( int  i)

Property documentation pending.

void QTreeView::setItemsExpandable ( bool  enable)

Property documentation pending.

void QTreeView::setModel ( QAbstractItemModel model)
overridevirtual

Reimplemented from QAbstractItemView::setModel().

Reimplemented from QAbstractItemView.

void QTreeView::setRootIndex ( const QModelIndex index)
override

Reimplemented from QAbstractItemView::setRootIndex().

void QTreeView::setRootIsDecorated ( bool  show)

Property documentation pending.

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 rectangle, rect.

See also
selectionCommand()

Implements QAbstractItemView.

void QTreeView::setSelectionModel ( QItemSelectionModel selectionModel)
overridevirtual

Reimplemented from QAbstractItemView::setSelectionModel().

Reimplemented from QAbstractItemView.

Reimplemented in QTreeWidget.

void QTreeView::setSortingEnabled ( bool  enable)

Property documentation pending.

void QTreeView::setTreePosition ( int  logicalIndex)

Property documentation pending.

void QTreeView::setUniformRowHeights ( bool  uniform)

Property documentation pending.

void QTreeView::setWordWrap ( bool  on)

Property documentation pending.

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

See also
QWidget::sizeHint, header()

Reimplemented from QAbstractItemView.

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 
)

Sets the model up for 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. Note that not all models support this and may even crash in this case.

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

Reimplemented from QObject::timerEvent().

int QTreeView::treePosition ( ) const

Property documentation pending.

bool QTreeView::uniformRowHeights ( ) const

Property documentation pending.

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

Reimplemented from QAbstractItemView::verticalOffset().

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

See also
horizontalOffset()

Implements QAbstractItemView.

bool QTreeView::viewportEvent ( QEvent event)
overrideprotectedvirtual

Reimplemented from QAbstractScrollArea::viewportEvent().

Reimplemented from QAbstractItemView.

QSize QTreeView::viewportSizeHint ( ) const
overrideprotectedvirtual

Property documentation pending.

Reimplemented from QAbstractItemView.

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.

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.

bool QTreeView::wordWrap ( ) const

Property documentation pending.

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 treeview will animate expansion and collapsing 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.

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

PropertiesClass Methods
read autoExpandDelay
write setAutoExpandDelay
QTreeView::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
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 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.

PropertiesClass Methods
read indentation
write setIndentation
QTreeView::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.

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. 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()
PropertiesClass Methods
read isSortingEnabled
write setSortingEnabled
QTreeView::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.

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

PropertiesClass Methods
read wordWrap
write setWordWrap