Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QAbstractItemView Class Referenceabstract

The QAbstractItemView class provides the basic functionality for item view classes. More...

#include <qabstractitemview.h>

+ Inheritance diagram for QAbstractItemView:
+ Collaboration diagram for QAbstractItemView:

Public Types

enum  SelectionMode {
  NoSelection , SingleSelection , MultiSelection , ExtendedSelection ,
  ContiguousSelection
}
 This enum indicates how the view responds to user selections: More...
 
enum  SelectionBehavior { SelectItems , SelectRows , SelectColumns }
 \value SelectItems Selecting single items. More...
 
enum  ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter }
 \value EnsureVisible Scroll to ensure that the item is visible. More...
 
enum  EditTrigger {
  NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 ,
  EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31
}
 This enum describes actions which will initiate item editing. More...
 
enum  ScrollMode { ScrollPerItem , ScrollPerPixel }
 

Public Slots

virtual void reset ()
 Reset the internal state of the view.
 
virtual void setRootIndex (const QModelIndex &index)
 Sets the root item to the item at the given index.
 
virtual void doItemsLayout ()
 
virtual void selectAll ()
 Selects all items in the view.
 
void edit (const QModelIndex &index)
 Starts editing the item corresponding to the given index if it is editable.
 
void clearSelection ()
 Deselects all selected items.
 
void setCurrentIndex (const QModelIndex &index)
 Sets the current item to be the item at index.
 
void scrollToTop ()
 
void scrollToBottom ()
 
void update (const QModelIndex &index)
 

Signals

void pressed (const QModelIndex &index)
 This signal is emitted when a mouse button is pressed.
 
void clicked (const QModelIndex &index)
 This signal is emitted when a mouse button is left-clicked.
 
void doubleClicked (const QModelIndex &index)
 This signal is emitted when a mouse button is double-clicked.
 
void activated (const QModelIndex &index)
 This signal is emitted when the item specified by index is activated by the user.
 
void entered (const QModelIndex &index)
 This signal is emitted when the mouse cursor enters the item specified by index.
 
void viewportEntered ()
 This signal is emitted when the mouse cursor enters the viewport.
 
void iconSizeChanged (const QSize &size)
 

Public Member Functions

 QAbstractItemView (QWidget *parent=nullptr)
 Constructs an abstract item view with the given parent.
 
 ~QAbstractItemView ()
 Destroys the view.
 
virtual void setModel (QAbstractItemModel *model)
 Sets the model for the view to present.
 
QAbstractItemModelmodel () const
 Returns the model that this view is presenting.
 
virtual void setSelectionModel (QItemSelectionModel *selectionModel)
 Sets the current selection model to the given selectionModel.
 
QItemSelectionModelselectionModel () const
 Returns the current selection model.
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 Sets the item delegate for this view and its model to delegate.
 
QAbstractItemDelegateitemDelegate () const
 Returns the item delegate used by this view and model.
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
QAbstractItemView::SelectionMode selectionMode () const
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QModelIndex currentIndex () const
 Returns the model index of the current item.
 
QModelIndex rootIndex () const
 Returns the model index of the model's root item.
 
void setEditTriggers (EditTriggers triggers)
 
EditTriggers editTriggers () const
 
void setVerticalScrollMode (ScrollMode mode)
 
ScrollMode verticalScrollMode () const
 
void resetVerticalScrollMode ()
 
void setHorizontalScrollMode (ScrollMode mode)
 
ScrollMode horizontalScrollMode () const
 
void resetHorizontalScrollMode ()
 
void setAutoScroll (bool enable)
 
bool hasAutoScroll () const
 
void setAutoScrollMargin (int margin)
 
int autoScrollMargin () const
 
void setTabKeyNavigation (bool enable)
 
bool tabKeyNavigation () const
 
void setAlternatingRowColors (bool enable)
 
bool alternatingRowColors () const
 
void setIconSize (const QSize &size)
 
QSize iconSize () const
 
void setTextElideMode (Qt::TextElideMode mode)
 
Qt::TextElideMode textElideMode () const
 
virtual void keyboardSearch (const QString &search)
 Moves to and selects the item best matching the string search.
 
virtual QRect visualRect (const QModelIndex &index) const =0
 Returns the rectangle on the viewport occupied by the item at index.
 
virtual void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
 Scrolls the view if necessary to ensure that the item at index is visible.
 
virtual QModelIndex indexAt (const QPoint &point) const =0
 Returns the model index of the item at the viewport coordinates point.
 
QSize sizeHintForIndex (const QModelIndex &index) const
 Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
 
virtual int sizeHintForRow (int row) const
 Returns the height size hint for the specified row or -1 if there is no model.
 
virtual int sizeHintForColumn (int column) const
 Returns the width size hint for the specified column or -1 if there is no model.
 
void openPersistentEditor (const QModelIndex &index)
 Opens a persistent editor on the item at the given index.
 
void closePersistentEditor (const QModelIndex &index)
 Closes the persistent editor for the item at the given index.
 
bool isPersistentEditorOpen (const QModelIndex &index) const
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 
QWidgetindexWidget (const QModelIndex &index) const
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 
virtual QAbstractItemDelegateitemDelegateForIndex (const QModelIndex &index) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 \reimp
 

Protected Types

enum  CursorAction {
  MoveUp , MoveDown , MoveLeft , MoveRight ,
  MoveHome , MoveEnd , MovePageUp , MovePageDown ,
  MoveNext , MovePrevious
}
 This enum describes the different ways to navigate between items,. More...
 
enum  State {
  NoState , DraggingState , DragSelectingState , EditingState ,
  ExpandingState , CollapsingState , AnimatingState
}
 Describes the different states the view can be in. More...
 

Protected Slots

virtual void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
 This slot is called when items with the given roles are changed in the model.
 
virtual void rowsInserted (const QModelIndex &parent, int start, int end)
 This slot is called when rows are inserted.
 
virtual void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 This slot is called when rows are about to be removed.
 
virtual void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 This slot is called when the selection is changed.
 
virtual void currentChanged (const QModelIndex &current, const QModelIndex &previous)
 This slot is called when a new item becomes the current item.
 
virtual void updateEditorData ()
 
virtual void updateEditorGeometries ()
 
virtual void updateGeometries ()
 
virtual void verticalScrollbarAction (int action)
 
virtual void horizontalScrollbarAction (int action)
 
virtual void verticalScrollbarValueChanged (int value)
 
virtual void horizontalScrollbarValueChanged (int value)
 
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 Closes the given editor, and releases it.
 
virtual void commitData (QWidget *editor)
 Commit the data in the editor to the model.
 
virtual void editorDestroyed (QObject *editor)
 This function is called when the given editor has been destroyed.
 

Protected Member Functions

 QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=nullptr)
 
virtual QModelIndex moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers)=0
 Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction and keyboard modifiers specified by modifiers.
 
virtual int horizontalOffset () const =0
 Returns the horizontal offset of the view.
 
virtual int verticalOffset () const =0
 Returns the vertical offset of the view.
 
virtual bool isIndexHidden (const QModelIndex &index) const =0
 Returns true if the item referred to by the given index is hidden in the view, otherwise returns false.
 
virtual void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
 Applies the selection flags to the items in or touched by the rectangle, rect.
 
virtual QRegion visualRegionForSelection (const QItemSelection &selection) const =0
 Returns the region from the viewport of the items in the given selection.
 
virtual QModelIndexList selectedIndexes () const
 This convenience function returns a list of all selected and non-hidden item indexes in the view.
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 Starts editing the item at index, creating an editor if necessary, and returns true if the view's \l{State} is now EditingState; otherwise returns false.
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 Returns the SelectionFlags to be used when updating a selection model for the specified index.
 
virtual void initViewItemOption (QStyleOptionViewItem *option) const
 
State state () const
 Returns the item view's state.
 
void setState (State state)
 Sets the item view's state to the given state.
 
void scheduleDelayedItemsLayout ()
 Schedules a layout of the items in the view to be executed when the event processing starts.
 
void executeDelayedItemsLayout ()
 Executes the scheduled layouts without waiting for the event processing to begin.
 
void setDirtyRegion (const QRegion &region)
 
void scrollDirtyRegion (int dx, int dy)
 Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite direction.
 
QPoint dirtyRegionOffset () const
 Returns the offset of the dirty regions in the view.
 
void startAutoScroll ()
 
void stopAutoScroll ()
 
void doAutoScroll ()
 
bool focusNextPrevChild (bool next) override
 \reimp
 
bool event (QEvent *event) override
 \reimp
 
bool viewportEvent (QEvent *event) override
 This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::ToolTip,or a QEvent::WhatsThis.
 
void mousePressEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is pressed while the cursor is inside the widget.
 
void mouseMoveEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse move event is sent to the widget.
 
void mouseReleaseEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is released, after a mouse press event on the widget.
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is double clicked inside the widget.
 
void focusInEvent (QFocusEvent *event) override
 This function is called with the given event when the widget obtains the focus.
 
void focusOutEvent (QFocusEvent *event) override
 This function is called with the given event when the widget loses the focus.
 
void keyPressEvent (QKeyEvent *event) override
 This function is called with the given event when a key event is sent to the widget.
 
void resizeEvent (QResizeEvent *event) override
 This function is called with the given event when a resize event is sent to the widget.
 
void timerEvent (QTimerEvent *event) override
 This function is called with the given event when a timer event is sent to the widget.
 
void inputMethodEvent (QInputMethodEvent *event) override
 \reimp
 
bool eventFilter (QObject *object, QEvent *event) override
 \reimp
 
QSize viewportSizeHint () const override
 

Properties

bool autoScroll
 whether autoscrolling in drag move events is enabled
 
int autoScrollMargin
 the size of the area when auto scrolling is triggered
 
EditTriggers editTriggers
 which actions will initiate item editing
 
bool tabKeyNavigation
 whether item navigation with tab and backtab is enabled.
 
bool alternatingRowColors
 whether to draw the background using alternating colors
 
SelectionMode selectionMode
 which selection mode the view operates in
 
SelectionBehavior selectionBehavior
 which selection behavior the view uses
 
QSize iconSize
 the size of items' icons
 
Qt::TextElideMode textElideMode
 the position of the "..." in elided text.
 
ScrollMode verticalScrollMode
 how the view scrolls its contents in the vertical direction
 
ScrollMode horizontalScrollMode
 how the view scrolls its contents in the horizontal direction
 

Friends

class ::tst_QAbstractItemView
 
class ::tst_QTreeView
 
class QTreeViewPrivate
 
class QListModeViewBase
 
class QListViewPrivate
 
class QAbstractSlider
 

Detailed Description

The QAbstractItemView class provides the basic functionality for item view classes.

\inmodule QtWidgets

QAbstractItemView class is the base class for every standard view that uses a QAbstractItemModel. QAbstractItemView is an abstract class and cannot itself be instantiated. It provides a standard interface for interoperating with models through the signals and slots mechanism, enabling subclasses to be kept up-to-date with changes to their models. This class provides standard support for keyboard and mouse navigation, viewport scrolling, item editing, and selections. The keyboard navigation implements this functionality:

\table \header

  • Keys
  • Functionality \row
  • Arrow keys
  • Changes the current item and selects it. \row
  • Ctrl+Arrow keys
  • Changes the current item but does not select it. \row
  • Shift+Arrow keys
  • Changes the current item and selects it. The previously selected item(s) is not deselected. \row
  • Ctrl+Space
  • Toggles selection of the current item. \row
  • Tab/Backtab
  • Changes the current item to the next/previous item. \row
  • Home/End
  • Selects the first/last item in the model. \row
  • Page up/Page down
  • Scrolls the rows shown up/down by the number of visible rows in the view. \row
  • Ctrl+A
  • Selects all items in the model. \endtable

Note that the above table assumes that the \l{selectionMode}{selection mode} allows the operations. For instance, you cannot select items if the selection mode is QAbstractItemView::NoSelection.

The QAbstractItemView class is one of the \l{Model/View Classes} and is part of Qt's \l{Model/View Programming}{model/view framework}.

The view classes that inherit QAbstractItemView only need to implement their own view-specific functionality, such as drawing items, returning the geometry of items, finding items, etc.

QAbstractItemView provides common slots such as edit() and setCurrentIndex(). Many protected slots are also provided, including dataChanged(), rowsInserted(), rowsAboutToBeRemoved(), selectionChanged(), and currentChanged().

The root item is returned by rootIndex(), and the current item by currentIndex(). To make sure that an item is visible use scrollTo().

Some of QAbstractItemView's functions are concerned with scrolling, for example setHorizontalScrollMode() and setVerticalScrollMode(). To set the range of the scroll bars, you can, for example, reimplement the view's resizeEvent() function:

void MyView::resizeEvent(QResizeEvent *event) {
horizontalScrollBar()->setRange(0, realWidth - width());
...
}

Note that the range is not updated until the widget is shown.

Several other functions are concerned with selection control; for example setSelectionMode(), and setSelectionBehavior(). This class provides a default selection model to work with (selectionModel()), but this can be replaced by using setSelectionModel() with an instance of QItemSelectionModel.

For complete control over the display and editing of items you can specify a delegate with setItemDelegate().

QAbstractItemView provides a lot of protected functions. Some are concerned with editing, for example, edit(), and commitData(), whilst others are keyboard and mouse event handlers.

Note
If you inherit QAbstractItemView and intend to update the contents of the viewport, you should use viewport->update() instead of \l{QWidget::update()}{update()} as all painting operations take place on the viewport.
See also
{View Classes}, {Model/View Programming}, QAbstractItemModel

Definition at line 25 of file qabstractitemview.h.

Member Enumeration Documentation

◆ CursorAction

This enum describes the different ways to navigate between items,.

See also
moveCursor()

\value MoveUp Move to the item above the current item. \value MoveDown Move to the item below the current item. \value MoveLeft Move to the item left of the current item. \value MoveRight Move to the item right of the current item. \value MoveHome Move to the top-left corner item. \value MoveEnd Move to the bottom-right corner item. \value MovePageUp Move one page up above the current item. \value MovePageDown Move one page down below the current item. \value MoveNext Move to the item after the current item. \value MovePrevious Move to the item before the current item.

Enumerator
MoveUp 
MoveDown 
MoveLeft 
MoveRight 
MoveHome 
MoveEnd 
MovePageUp 
MovePageDown 
MoveNext 
MovePrevious 

Definition at line 248 of file qabstractitemview.h.

◆ EditTrigger

This enum describes actions which will initiate item editing.

\value NoEditTriggers No editing possible. \value CurrentChanged Editing start whenever current item changes. \value DoubleClicked Editing starts when an item is double clicked. \value SelectedClicked Editing starts when clicking on an already selected item. \value EditKeyPressed Editing starts when the platform edit key has been pressed over an item. \value AnyKeyPressed Editing starts when any key is pressed over an item. \value AllEditTriggers Editing starts for all above actions.

Enumerator
NoEditTriggers 
CurrentChanged 
DoubleClicked 
SelectedClicked 
EditKeyPressed 
AnyKeyPressed 
AllEditTriggers 

Definition at line 75 of file qabstractitemview.h.

◆ ScrollHint

\value EnsureVisible Scroll to ensure that the item is visible.

\value PositionAtTop Scroll to position the item at the top of the viewport. \value PositionAtBottom Scroll to position the item at the bottom of the viewport. \value PositionAtCenter Scroll to position the item at the center of the viewport.

Enumerator
EnsureVisible 
PositionAtTop 
PositionAtBottom 
PositionAtCenter 

Definition at line 67 of file qabstractitemview.h.

◆ ScrollMode

Since
4.2

Describes how the scrollbar should behave. When setting the scroll mode to ScrollPerPixel the single step size will adjust automatically unless it was set explicitly using \l{QAbstractSlider::}{setSingleStep()}. The automatic adjustment can be restored by setting the single step size to -1.

\value ScrollPerItem The view will scroll the contents one item at a time. \value ScrollPerPixel The view will scroll the contents one pixel at a time.

Enumerator
ScrollPerItem 
ScrollPerPixel 

Definition at line 88 of file qabstractitemview.h.

◆ SelectionBehavior

\value SelectItems Selecting single items.

\value SelectRows Selecting only rows. \value SelectColumns Selecting only columns.

Enumerator
SelectItems 
SelectRows 
SelectColumns 

Definition at line 60 of file qabstractitemview.h.

◆ SelectionMode

This enum indicates how the view responds to user selections:

\value SingleSelection When the user selects an item, any already-selected item becomes unselected. It is possible for the user to deselect the selected item by pressing the Ctrl key when clicking the selected item.

\value ContiguousSelection When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item.

\value ExtendedSelection When the user selects an item in the usual way, the selection is cleared and the new item selected. However, if the user presses the Ctrl key when clicking on an item, the clicked item gets toggled and all other items are left untouched. If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected or unselected, depending on the state of the clicked item. Multiple items can be selected by dragging the mouse over them.

\value MultiSelection When the user selects an item in the usual way, the selection status of that item is toggled and the other items are left alone. Multiple items can be toggled by dragging the mouse over them.

\value NoSelection Items cannot be selected.

The most commonly used modes are SingleSelection and ExtendedSelection.

Enumerator
NoSelection 
SingleSelection 
MultiSelection 
ExtendedSelection 
ContiguousSelection 

Definition at line 51 of file qabstractitemview.h.

◆ State

enum QAbstractItemView::State
protected

Describes the different states the view can be in.

This is usually only interesting when reimplementing your own view.

\value NoState The is the default state. \value DraggingState The user is dragging items. \value DragSelectingState The user is selecting items. \value EditingState The user is editing an item in a widget editor. \value ExpandingState The user is opening a branch of items. \value CollapsingState The user is closing a branch of items. \value AnimatingState The item view is performing an animation.

Enumerator
NoState 
DraggingState 
DragSelectingState 
EditingState 
ExpandingState 
CollapsingState 
AnimatingState 

Definition at line 274 of file qabstractitemview.h.

Constructor & Destructor Documentation

◆ QAbstractItemView() [1/2]

QAbstractItemView::QAbstractItemView ( QWidget * parent = nullptr)
explicit

Constructs an abstract item view with the given parent.

Definition at line 663 of file qabstractitemview.cpp.

◆ ~QAbstractItemView()

QAbstractItemView::~QAbstractItemView ( )

Destroys the view.

Definition at line 681 of file qabstractitemview.cpp.

References d.

◆ QAbstractItemView() [2/2]

QAbstractItemView::QAbstractItemView ( QAbstractItemViewPrivate & dd,
QWidget * parent = nullptr )
protected

Definition at line 672 of file qabstractitemview.cpp.

Member Function Documentation

◆ activated

void QAbstractItemView::activated ( const QModelIndex & index)
signal

This signal is emitted when the item specified by index is activated by the user.

How to activate items depends on the platform; e.g., by single- or double-clicking the item, or by pressing the Return or Enter key when the item is current.

See also
clicked(), doubleClicked(), entered(), pressed()

Referenced by QTreeWidget::QTreeWidget(), QFileDialogPrivate::createWidgets(), keyPressEvent(), mouseDoubleClickEvent(), QTreeView::mouseDoubleClickEvent(), mouseReleaseEvent(), QListWidgetPrivate::setup(), and QTableWidgetPrivate::setup().

+ Here is the caller graph for this function:

◆ alternatingRowColors()

bool QAbstractItemView::alternatingRowColors ( ) const

Definition at line 1611 of file qabstractitemview.cpp.

References d.

◆ autoScrollMargin()

int QAbstractItemView::autoScrollMargin ( ) const

Definition at line 1440 of file qabstractitemview.cpp.

References d.

◆ clearSelection

void QAbstractItemView::clearSelection ( )
slot

Deselects all selected items.

The current index will not be changed.

See also
setSelection(), selectAll()

Definition at line 1247 of file qabstractitemview.cpp.

References d.

Referenced by QFontDialogPrivate::sizeChanged().

+ Here is the caller graph for this function:

◆ clicked

void QAbstractItemView::clicked ( const QModelIndex & index)
signal

This signal is emitted when a mouse button is left-clicked.

The item the mouse was clicked on is specified by index. The signal is only emitted when the index is valid.

See also
activated(), doubleClicked(), entered(), pressed()

Referenced by QTreeWidget::QTreeWidget(), mouseReleaseEvent(), QListWidgetPrivate::setup(), QTableWidgetPrivate::setup(), and src_gui_itemviews_qstandarditemmodel::MyWidget::wrapper2().

+ Here is the caller graph for this function:

◆ closeEditor

void QAbstractItemView::closeEditor ( QWidget * editor,
QAbstractItemDelegate::EndEditHint hint )
protectedvirtualslot

Closes the given editor, and releases it.

The hint is used to specify how the view should respond to the end of the editing operation. For example, the hint may indicate that the next item in the view should be opened for editing.

See also
edit(), commitData()

Definition at line 2933 of file qabstractitemview.cpp.

References QItemSelectionModel::ClearAndSelect, CurrentChanged, d, edit, QAbstractItemDelegate::EditNextItem, QAbstractItemDelegate::EditPreviousItem, editTriggers, hint(), itemDelegateForIndex(), Qt::ItemIsEditable, moveCursor(), MoveNext, MovePrevious, Qt::NoFocus, Qt::NoModifier, NoSelection, NoState, QItemSelectionModel::NoUpdate, qWarning, QAbstractItemDelegate::RevertModelCache, QCoreApplication::sendPostedEvents(), setState(), and QAbstractItemDelegate::SubmitModelCache.

Referenced by closePersistentEditor(), and currentChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closePersistentEditor()

void QAbstractItemView::closePersistentEditor ( const QModelIndex & index)

Closes the persistent editor for the item at the given index.

See also
openPersistentEditor(), isPersistentEditorOpen()

Definition at line 3252 of file qabstractitemview.cpp.

References closeEditor(), currentIndex(), d, QAbstractItemDelegate::RevertModelCache, and selectionModel().

Referenced by QListWidget::closePersistentEditor(), QTableWidget::closePersistentEditor(), and QTreeWidget::closePersistentEditor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commitData

void QAbstractItemView::commitData ( QWidget * editor)
protectedvirtualslot

Commit the data in the editor to the model.

See also
closeEditor()

Definition at line 3026 of file qabstractitemview.cpp.

References d, itemDelegateForIndex(), qWarning, and QAbstractItemDelegate::setModelData().

Referenced by currentChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentChanged

void QAbstractItemView::currentChanged ( const QModelIndex & current,
const QModelIndex & previous )
protectedvirtualslot

This slot is called when a new item becomes the current item.

The previous current item is specified by the previous index, and the new item by the current index.

If you want to know about changes to items see the dataChanged() signal.

Reimplemented in QHeaderView, QFontListView, QColumnView, QListView, QTableView, and QTreeView.

Definition at line 3802 of file qabstractitemview.cpp.

References closeEditor(), commitData(), CurrentChanged, d, edit, QModelIndex::flags(), QModelIndex::isValid(), isVisible(), Qt::ItemIsEditable, QModelIndex::model(), QAbstractItemDelegate::NoHint, Q_ASSERT, QModelIndex::row(), scrollTo(), setAttribute(), QAbstractItemDelegate::SubmitModelCache, update(), and Qt::WA_InputMethodEnabled.

Referenced by QListView::currentChanged(), QTableView::currentChanged(), QTreeView::currentChanged(), and setSelectionModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentIndex()

◆ dataChanged

void QAbstractItemView::dataChanged ( const QModelIndex & topLeft,
const QModelIndex & bottomRight,
const QList< int > & roles = QList<int>() )
protectedvirtualslot

This slot is called when items with the given roles are changed in the model.

The changed items are those from topLeft to bottomRight inclusive. If just one item is changed topLeft == bottomRight.

The roles which have been changed can either be an empty container (meaning everything has changed), or a non-empty container with the subset of roles which have changed.

Note
: Qt::ToolTipRole is not honored by dataChanged() in the views provided by Qt.

Reimplemented in QHeaderView, QListView, and QTreeView.

Definition at line 3403 of file qabstractitemview.cpp.

References QModelIndex::column(), d, QRect::isEmpty(), QModelIndex::isValid(), isVisible(), itemDelegateForIndex(), QModelIndex::parent(), Q_UNUSED, QModelIndex::row(), QAbstractItemDelegate::setEditorData(), and update().

Referenced by QListView::dataChanged(), QTreeView::dataChanged(), setIndexWidget(), and setModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dirtyRegionOffset()

QPoint QAbstractItemView::dirtyRegionOffset ( ) const
protected

Returns the offset of the dirty regions in the view.

If you use scrollDirtyRegion() and implement a paintEvent() in a subclass of QAbstractItemView, you should translate the area given by the paint event with the offset returned from this function.

See also
scrollDirtyRegion(), setDirtyRegion()

Definition at line 4008 of file qabstractitemview.cpp.

References d.

◆ doAutoScroll()

void QAbstractItemView::doAutoScroll ( )
protected

Definition at line 4033 of file qabstractitemview.cpp.

References area(), d, DraggingState, DragSelectingState, QWidgetPrivate::get(), Qt::Horizontal, Qt::LeftButton, Qt::MouseEventSynthesizedByQt, QEvent::MouseMove, Qt::NoButton, QAbstractSlider::pageStep, pos, qMax(), QCoreApplication::sendEvent(), QAbstractSlider::setValue(), state(), stopAutoScroll(), QAbstractSlider::value, viewport(), and window().

Referenced by timerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doItemsLayout

void QAbstractItemView::doItemsLayout ( )
virtualslot

This function is intended to lay out the items in the view. The default implementation just calls updateGeometries() and updates the viewport.

Reimplemented in QHeaderView, QListView, QTableView, and QTreeView.

Definition at line 1260 of file qabstractitemview.cpp.

References d, and updateGeometries().

Referenced by QAbstractItemViewPrivate::delegateSizeHintChanged(), QHeaderView::doItemsLayout(), QListView::doItemsLayout(), QTableView::doItemsLayout(), QTreeView::doItemsLayout(), event(), and timerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doubleClicked

void QAbstractItemView::doubleClicked ( const QModelIndex & index)
signal

This signal is emitted when a mouse button is double-clicked.

The item the mouse was double-clicked on is specified by index. The signal is only emitted when the index is valid.

See also
clicked(), activated()

Referenced by QTreeWidget::QTreeWidget(), mouseDoubleClickEvent(), QTreeView::mouseDoubleClickEvent(), QListWidgetPrivate::setup(), and QTableWidgetPrivate::setup().

+ Here is the caller graph for this function:

◆ edit [1/2]

void QAbstractItemView::edit ( const QModelIndex & index)
slot

Starts editing the item corresponding to the given index if it is editable.

Note that this function does not change the current index. Since the current index defines the next and previous items to edit, users may find that keyboard navigation does not work as expected. To provide consistent navigation behavior, call setCurrentIndex() before this function with the same model index.

See also
QModelIndex::flags()

Definition at line 1233 of file qabstractitemview.cpp.

References AllEditTriggers, d, edit, Q_UNLIKELY, and qWarning.

Referenced by QFileDialogPrivate::createDirectory().

+ Here is the caller graph for this function:

◆ edit() [2/2]

bool QAbstractItemView::edit ( const QModelIndex & index,
EditTrigger trigger,
QEvent * event )
protectedvirtual

Starts editing the item at index, creating an editor if necessary, and returns true if the view's \l{State} is now EditingState; otherwise returns false.

The action that caused the editing process is described by trigger, and the associated event is specified by event.

Editing can be forced by specifying the trigger to be QAbstractItemView::AllEditTriggers.

See also
closeEditor()

Definition at line 2749 of file qabstractitemview.cpp.

References CurrentChanged, d, DoubleClicked, QApplication::doubleClickInterval, Qt::NoFocus, SelectedClicked, and update().

+ Here is the call graph for this function:

◆ editorDestroyed

void QAbstractItemView::editorDestroyed ( QObject * editor)
protectedvirtualslot

This function is called when the given editor has been destroyed.

See also
closeEditor()

Definition at line 3049 of file qabstractitemview.cpp.

References d, EditingState, NoState, qobject_cast< QWidget * >(), setState(), and state().

Referenced by QAbstractItemViewPrivate::editor(), QAbstractItemViewPrivate::releaseEditor(), and QAbstractItemViewPrivate::removeEditor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editTriggers()

QAbstractItemView::EditTriggers QAbstractItemView::editTriggers ( ) const

Definition at line 1283 of file qabstractitemview.cpp.

References d.

◆ entered

void QAbstractItemView::entered ( const QModelIndex & index)
signal

This signal is emitted when the mouse cursor enters the item specified by index.

Mouse tracking needs to be enabled for this feature to work.

See also
viewportEntered(), activated(), clicked(), doubleClicked(), pressed()

Referenced by QTreeWidget::QTreeWidget(), QListWidgetPrivate::setup(), and QTableWidgetPrivate::setup().

+ Here is the caller graph for this function:

◆ event()

bool QAbstractItemView::event ( QEvent * event)
overrideprotected

\reimp

Definition at line 1676 of file qabstractitemview.cpp.

References QEvent::ApplicationLayoutDirectionChange, currentIndex(), d, doItemsLayout(), EditingState, QEvent::FocusOut, QEvent::FontChange, QModelIndex::isValid(), QEvent::LayoutDirectionChange, QEvent::LocaleChange, QEvent::Paint, resetHorizontalScrollMode(), resetVerticalScrollMode(), scrollTo(), QEvent::Show, QEvent::StyleChange, updateGeometries(), and viewport().

Referenced by QHeaderView::event(), QListView::event(), QTableWidget::event(), QTreeWidget::event(), and QtPrivate::QCalendarView::event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eventFilter()

bool QAbstractItemView::eventFilter ( QObject * object,
QEvent * event )
overrideprotected

\reimp

Definition at line 4766 of file qabstractitemview.cpp.

References d, QEvent::FocusIn, qobject_cast< QWidget * >(), setCurrentIndex(), viewport(), and widget.

+ Here is the call graph for this function:

◆ executeDelayedItemsLayout()

void QAbstractItemView::executeDelayedItemsLayout ( )
protected

Executes the scheduled layouts without waiting for the event processing to begin.

See also
scheduleDelayedItemsLayout()

Definition at line 3961 of file qabstractitemview.cpp.

References d.

Referenced by viewportEvent().

+ Here is the caller graph for this function:

◆ focusInEvent()

void QAbstractItemView::focusInEvent ( QFocusEvent * event)
overrideprotected

This function is called with the given event when the widget obtains the focus.

By default, the event is ignored.

See also
setFocus(), focusOutEvent()

Definition at line 2292 of file qabstractitemview.cpp.

References autoScroll, currentIndex(), d, QModelIndex::isValid(), Qt::ItemIsEditable, model(), Qt::MouseFocusReason, moveCursor(), MoveNext, Qt::NoModifier, QItemSelectionModel::NoUpdate, selectionModel(), setAttribute(), QItemSelectionModel::setCurrentIndex(), and Qt::WA_InputMethodEnabled.

+ Here is the call graph for this function:

◆ focusNextPrevChild()

bool QAbstractItemView::focusNextPrevChild ( bool next)
overrideprotected

\reimp

Definition at line 1661 of file qabstractitemview.cpp.

References d, isVisible(), Qt::Key_Backtab, Qt::Key_Tab, QEvent::KeyPress, keyPressEvent(), next, and Qt::NoModifier.

+ Here is the call graph for this function:

◆ focusOutEvent()

void QAbstractItemView::focusOutEvent ( QFocusEvent * event)
overrideprotected

This function is called with the given event when the widget loses the focus.

By default, the event is ignored.

See also
clearFocus(), focusInEvent()

Definition at line 2327 of file qabstractitemview.cpp.

References d.

◆ hasAutoScroll()

bool QAbstractItemView::hasAutoScroll ( ) const

Definition at line 1420 of file qabstractitemview.cpp.

References d.

◆ horizontalOffset()

int QAbstractItemView::horizontalOffset ( ) const
protectedpure virtual

Returns the horizontal offset of the view.

In the base class this is a pure virtual function.

See also
verticalOffset()

Implemented in QColumnView, QColumnViewPreviewColumn, QHeaderView, QListView, QTableView, and QTreeView.

◆ horizontalScrollbarAction

void QAbstractItemView::horizontalScrollbarAction ( int action)
protectedvirtualslot

Reimplemented in QTableView, and QTreeView.

Definition at line 2919 of file qabstractitemview.cpp.

Referenced by QTableView::horizontalScrollbarAction(), QTreeView::horizontalScrollbarAction(), and QAbstractItemViewPrivate::init().

+ Here is the caller graph for this function:

◆ horizontalScrollbarValueChanged

void QAbstractItemView::horizontalScrollbarValueChanged ( int value)
protectedvirtualslot

Definition at line 2898 of file qabstractitemview.cpp.

References contains(), d, QCursor::pos(), rect, and viewport().

Referenced by QAbstractItemViewPrivate::init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ horizontalScrollMode()

QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode ( ) const

Definition at line 1352 of file qabstractitemview.cpp.

References d.

◆ iconSize()

QSize QAbstractItemView::iconSize ( ) const

Definition at line 1634 of file qabstractitemview.cpp.

References d.

◆ iconSizeChanged

void QAbstractItemView::iconSizeChanged ( const QSize & size)
signal

Referenced by setIconSize().

+ Here is the caller graph for this function:

◆ indexAt()

QModelIndex QAbstractItemView::indexAt ( const QPoint & point) const
pure virtual

Returns the model index of the item at the viewport coordinates point.

In the base class this is a pure virtual function.

See also
visualRect()

Implemented in QColumnViewPreviewColumn, QHeaderView, QListView, QTableView, QTreeView, and QColumnView.

Referenced by QComboBoxPrivateContainer::eventFilter(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), setVerticalScrollMode(), and viewportEvent().

+ Here is the caller graph for this function:

◆ indexWidget()

QWidget * QAbstractItemView::indexWidget ( const QModelIndex & index) const
Since
4.1

Returns the widget for the item at the given index.

Definition at line 3335 of file qabstractitemview.cpp.

References d.

Referenced by QTableWidget::cellWidget(), QTreeView::drawRow(), QListWidget::itemWidget(), QTreeWidget::itemWidget(), keyPressEvent(), and setIndexWidget().

+ Here is the caller graph for this function:

◆ initViewItemOption()

void QAbstractItemView::initViewItemOption ( QStyleOptionViewItem * option) const
protectedvirtual
Since
6.0

Initialize the option structure with the view's palette, font, state, alignments etc.

Note
Implementations of this methods should check the \l{QStyleOption::}{version} of the structure received, populate all members the implementation is familiar with, and set the version member to the one supported by the implementation before returning.

Reimplemented in QListView, QTableView, and QComboBoxListView.

Definition at line 3886 of file qabstractitemview.cpp.

References Qt::AlignCenter, Qt::AlignLeft, Qt::AlignVCenter, d, font, QLocale::OmitGroupSeparator, QStyle::pixelMetric(), QStyle::PM_SmallIconSize, and QStyle::SH_ItemView_ShowDecorationSelected.

Referenced by QTreeView::drawBranches(), QTreeView::drawTree(), QTreeView::indexRowSizeHint(), QListView::initViewItemOption(), QTableView::initViewItemOption(), mouseReleaseEvent(), openPersistentEditor(), sizeHintForColumn(), QTreeView::sizeHintForColumn(), sizeHintForIndex(), sizeHintForRow(), updateEditorGeometries(), and viewportEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inputMethodEvent()

void QAbstractItemView::inputMethodEvent ( QInputMethodEvent * event)
overrideprotected

\reimp

Definition at line 2632 of file qabstractitemview.cpp.

References AnyKeyPressed, currentIndex(), d, edit, itemDelegateForIndex(), keyboardSearch(), Qt::NoFocus, QCoreApplication::sendEvent(), QAbstractItemDelegate::setEditorData(), and widget.

+ Here is the call graph for this function:

◆ inputMethodQuery()

QVariant QAbstractItemView::inputMethodQuery ( Qt::InputMethodQuery query) const
overridevirtual

\reimp

Reimplemented in QInputDialogListView.

Definition at line 890 of file qabstractitemview.cpp.

References currentIndex(), d, Qt::ImCursorRectangle, QModelIndex::isValid(), visualRect(), and widget.

Referenced by QInputDialogListView::inputMethodQuery().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isIndexHidden()

bool QAbstractItemView::isIndexHidden ( const QModelIndex & index) const
protectedpure virtual

Returns true if the item referred to by the given index is hidden in the view, otherwise returns false.

Hiding is a view specific feature. For example in TableView a column can be marked as hidden or a row in the TreeView.

In the base class this is a pure virtual function.

Implemented in QColumnViewPreviewColumn, QColumnView, QHeaderView, QListView, QTableView, and QTreeView.

Referenced by rowsAboutToBeRemoved(), and selectedIndexes().

+ Here is the caller graph for this function:

◆ isPersistentEditorOpen()

bool QAbstractItemView::isPersistentEditorOpen ( const QModelIndex & index) const
Since
5.10

Returns whether a persistent editor is open for the item at index index.

See also
openPersistentEditor(), closePersistentEditor()

Definition at line 3271 of file qabstractitemview.cpp.

References d.

Referenced by QListWidget::isPersistentEditorOpen(), QTableWidget::isPersistentEditorOpen(), and QTreeWidget::isPersistentEditorOpen().

+ Here is the caller graph for this function:

◆ itemDelegate()

QAbstractItemDelegate * QAbstractItemView::itemDelegate ( ) const

Returns the item delegate used by this view and model.

This is either one set with setItemDelegate(), or the default one.

See also
setItemDelegate()
Deprecated
Use itemDelegateForIndex() instead. Returns the item delegate used by this view and model for the given index.

Definition at line 882 of file qabstractitemview.cpp.

Referenced by QComboBox::itemDelegate().

+ Here is the caller graph for this function:

◆ itemDelegateForColumn()

QAbstractItemDelegate * QAbstractItemView::itemDelegateForColumn ( int column) const
Since
4.2

Returns the item delegate used by this view and model for the given column. You can call itemDelegate() to get a pointer to the current delegate for a given index.

See also
setItemDelegateForColumn(), itemDelegateForRow(), itemDelegate()

Definition at line 1013 of file qabstractitemview.cpp.

References d.

◆ itemDelegateForIndex()

QAbstractItemDelegate * QAbstractItemView::itemDelegateForIndex ( const QModelIndex & index) const
virtual
Since
6.0

Returns the item delegate used by this view and model for the given index.

See also
setItemDelegate(), setItemDelegateForRow(), setItemDelegateForColumn()

Definition at line 1034 of file qabstractitemview.cpp.

References d.

Referenced by closeEditor(), commitData(), dataChanged(), QCommonListViewBase::delegate(), QTreeView::drawRow(), QTreeView::indexRowSizeHint(), inputMethodEvent(), QListView::paintEvent(), sizeHintForColumn(), sizeHintForIndex(), sizeHintForRow(), updateEditorGeometries(), and viewportEvent().

+ Here is the caller graph for this function:

◆ itemDelegateForRow()

QAbstractItemDelegate * QAbstractItemView::itemDelegateForRow ( int row) const
Since
4.2

Returns the item delegate used by this view and model for the given row, or \nullptr if no delegate has been assigned. You can call itemDelegate() to get a pointer to the current delegate for a given index.

See also
setItemDelegateForRow(), itemDelegateForColumn(), setItemDelegate()

Definition at line 961 of file qabstractitemview.cpp.

References d.

◆ keyboardSearch()

void QAbstractItemView::keyboardSearch ( const QString & search)
virtual

Moves to and selects the item best matching the string search.

If no item is found nothing happens.

In the default implementation, the search is reset if search is empty, or the time interval since the last search has exceeded QApplication::keyboardInputInterval().

Reimplemented in QtPrivate::QCalendarView, and QTreeView.

Definition at line 3069 of file qabstractitemview.cpp.

References QString::count(), currentIndex(), d, Qt::DisplayRole, QString::isEmpty(), QModelIndex::isValid(), QApplication::keyboardInputInterval, match(), QModelIndex::parent(), setCurrentIndex(), and QModelIndex::sibling().

Referenced by inputMethodEvent(), and keyPressEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ keyPressEvent()

void QAbstractItemView::keyPressEvent ( QKeyEvent * event)
overrideprotected

This function is called with the given event when a key event is sent to the widget.

The default implementation handles basic cursor movement, e.g. Up, Down, Left, Right, Home, PageUp, and PageDown; the activated() signal is emitted if the current index is valid and the activation key is pressed (e.g. Enter or Return, depending on the platform). This function is where editing is initiated by key press, e.g. if F2 is pressed.

See also
edit(), moveCursor(), keyboardSearch(), tabKeyNavigation

Definition at line 2345 of file qabstractitemview.cpp.

References activated(), Qt::AltModifier, AnyKeyPressed, QVariant::canConvert(), QGuiApplication::clipboard(), Qt::ControlModifier, QKeySequence::Copy, QItemSelectionModel::Current, currentIndex(), d, QVariant::data(), Qt::DisplayRole, edit, EditingState, EditKeyPressed, emit, QApplication::focusWidget(), Qt::Horizontal, indexWidget(), QPersistentModelIndex::isValid(), Qt::Key_Back, Qt::Key_Backspace, Qt::Key_Backtab, Qt::Key_Control, Qt::Key_Delete, Qt::Key_Down, Qt::Key_End, Qt::Key_Enter, Qt::Key_Escape, Qt::Key_F2, Qt::Key_Home, Qt::Key_Left, Qt::Key_O, Qt::Key_PageDown, Qt::Key_PageUp, Qt::Key_Return, Qt::Key_Right, Qt::Key_Select, Qt::Key_Shift, Qt::Key_Space, Qt::Key_Tab, Qt::Key_Up, keyboardSearch(), Qt::MetaModifier, moveCursor(), MoveDown, MoveEnd, MoveHome, MoveLeft, MoveNext, MovePageDown, MovePageUp, MovePrevious, MoveRight, MoveUp, Qt::NavigationModeKeypadDirectional, NoSelection, QItemSelectionModel::NoUpdate, rect, QKeySequence::SelectAll, selectAll(), selectionCommand(), selectionMode, setSelection(), QStyle::SH_ItemView_MovementWithoutUpdatingSelection, state(), QVariant::toString(), variant, Qt::Vertical, and visualRect().

Referenced by focusNextPrevChild(), QFileDialogListView::keyPressEvent(), QTreeView::keyPressEvent(), and QtPrivate::QCalendarView::keyPressEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ model()

QAbstractItemModel * QAbstractItemView::model ( ) const

Returns the model that this view is presenting.

Definition at line 770 of file qabstractitemview.cpp.

References d, and QAbstractItemModelPrivate::staticEmptyModel().

Referenced by QTreeWidget::QTreeWidget(), QTableWidget::cellWidget(), QTableWidget::dropMimeData(), QTreeWidget::dropMimeData(), QtPrivate::QCalendarView::event(), QListWidget::findItems(), QTableWidget::findItems(), QTreeWidget::findItems(), focusInEvent(), QtPrivate::QCalendarView::handleMouseEvent(), QTableWidgetItem::isSelected(), QtPrivate::QCalendarView::keyPressEvent(), QTreeWidget::mimeTypes(), QFontListView::model(), QtPrivate::QCalendarView::mouseDoubleClickEvent(), QtPrivate::QCalendarView::mouseMoveEvent(), QtPrivate::QCalendarView::mousePressEvent(), QtPrivate::QCalendarView::mouseReleaseEvent(), QTableView::moveCursor(), QTreeView::moveCursor(), QtPrivate::QCalendarView::moveCursor(), QSidebar::selectUrl(), QTableWidget::setCellWidget(), QTableWidget::setCurrentCell(), QTableWidget::setCurrentCell(), QTableWidget::setHorizontalHeaderLabels(), setModel(), QHeaderView::setModel(), QTableView::setModel(), QTreeView::setModel(), QSidebar::setModelAndUrls(), QTableWidget::setRangeSelected(), QTableWidgetItem::setSelected(), QTableWidget::setVerticalHeaderLabels(), QComboBox::setView(), QCompleterPrivate::showPopup(), QSidebar::sizeHint(), QTableView::sizeHintForColumn(), QTableView::sizeHintForRow(), and QTreeWidget::supportedDropActions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void QAbstractItemView::mouseDoubleClickEvent ( QMouseEvent * event)
overrideprotected

This function is called with the given event when a mouse button is double clicked inside the widget.

If the double-click is on a valid item it emits the doubleClicked() signal and calls edit() on the item.

Definition at line 2005 of file qabstractitemview.cpp.

References activated(), d, DoubleClicked, doubleClicked(), edit, emit, indexAt(), Qt::LeftButton, QEvent::MouseButtonPress, mousePressEvent(), and QStyle::SH_ItemView_ActivateItemOnSingleClick.

Referenced by QtPrivate::QCalendarView::mouseDoubleClickEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mouseMoveEvent()

void QAbstractItemView::mouseMoveEvent ( QMouseEvent * event)
overrideprotected

This function is called with the given event when a mouse move event is sent to the widget.

If a selection is in progress and new items are moved over the selection is extended; if a drag is in progress it is continued.

Definition at line 1883 of file qabstractitemview.cpp.

References CollapsingState, d, DraggingState, DragSelectingState, edit, EditingState, ExpandingState, indexAt(), Qt::LeftButton, QModelIndex::model(), Qt::NoButton, NoEditTriggers, QItemSelectionModel::NoUpdate, selectionCommand(), setSelection(), setState(), SingleSelection, startAutoScroll(), state(), and QItemSelectionModel::Toggle.

Referenced by QListView::mouseMoveEvent(), QTreeView::mouseMoveEvent(), and QtPrivate::QCalendarView::mouseMoveEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mousePressEvent()

void QAbstractItemView::mousePressEvent ( QMouseEvent * event)
overrideprotected

This function is called with the given event when a mouse button is pressed while the cursor is inside the widget.

If a valid item is pressed on it is made into the current item. This function emits the pressed() signal.

Definition at line 1806 of file qabstractitemview.cpp.

References autoScroll, QItemSelectionModel::Current, currentIndex(), d, QItemSelectionModel::Deselect, QApplication::doubleClickInterval, edit, EditingState, emit, indexAt(), QItemSelectionModel::isSelected(), NoEditTriggers, QItemSelectionModel::NoUpdate, pos, pressed(), rect, QItemSelectionModel::Select, selectionCommand(), setSelection(), QItemSelectionModel::Toggle, and visualRect().

Referenced by mouseDoubleClickEvent(), QTreeView::mousePressEvent(), and QtPrivate::QCalendarView::mousePressEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mouseReleaseEvent()

void QAbstractItemView::mouseReleaseEvent ( QMouseEvent * event)
overrideprotected

This function is called with the given event when a mouse button is released, after a mouse press event on the widget.

If a user presses the mouse inside your widget and then drags the mouse to another location before releasing the mouse button, your widget receives the release event. The function will emit the clicked() signal if an item was being pressed.

Definition at line 1950 of file qabstractitemview.cpp.

References activated(), clicked(), d, edit, EditingState, emit, indexAt(), initViewItemOption(), Qt::ItemIsEnabled, Qt::LeftButton, NoEditTriggers, Qt::NoModifier, NoState, QItemSelectionModel::NoUpdate, pos, SelectedClicked, selectionCommand(), setState(), QStyle::SH_ItemView_ActivateItemOnSingleClick, state(), QStyle::State_Selected, and update().

Referenced by QListView::mouseReleaseEvent(), QTreeView::mouseReleaseEvent(), and QtPrivate::QCalendarView::mouseReleaseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveCursor()

QModelIndex QAbstractItemView::moveCursor ( CursorAction cursorAction,
Qt::KeyboardModifiers modifiers )
protectedpure virtual

Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction and keyboard modifiers specified by modifiers.

In the base class this is a pure virtual function.

Implemented in QColumnView, QListView, QTableView, QTreeView, QtPrivate::QCalendarView, QColumnViewPreviewColumn, and QHeaderView.

Referenced by closeEditor(), focusInEvent(), and keyPressEvent().

+ Here is the caller graph for this function:

◆ openPersistentEditor()

void QAbstractItemView::openPersistentEditor ( const QModelIndex & index)

Opens a persistent editor on the item at the given index.

If no editor exists, the delegate will create a new editor.

See also
closePersistentEditor(), isPersistentEditorOpen()

Definition at line 3232 of file qabstractitemview.cpp.

References currentIndex(), d, initViewItemOption(), QStyle::State_HasFocus, QStyle::State_None, and visualRect().

Referenced by QListWidget::openPersistentEditor(), QTableWidget::openPersistentEditor(), and QTreeWidget::openPersistentEditor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pressed

void QAbstractItemView::pressed ( const QModelIndex & index)
signal

This signal is emitted when a mouse button is pressed.

The item the mouse was pressed on is specified by index. The signal is only emitted when the index is valid.

Use the QGuiApplication::mouseButtons() function to get the state of the mouse buttons.

See also
activated(), clicked(), doubleClicked(), entered()

Referenced by QTreeWidget::QTreeWidget(), mousePressEvent(), QListWidgetPrivate::setup(), and QTableWidgetPrivate::setup().

+ Here is the caller graph for this function:

◆ reset

void QAbstractItemView::reset ( )
virtualslot

Reset the internal state of the view.

Warning
This function will reset open editors, scroll bar positions, selections, etc. Existing changes will not be committed. If you would like to save your changes when resetting the view, you can reimplement this function, commit your changes, and then call the superclass' implementation.

Reimplemented in QHeaderView, QListView, and QTreeView.

Definition at line 1131 of file qabstractitemview.cpp.

References copy(), d, info, NoState, setRootIndex(), and setState().

Referenced by QHeaderView::reset(), QListView::reset(), QTreeView::reset(), setModel(), and timerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetHorizontalScrollMode()

void QAbstractItemView::resetHorizontalScrollMode ( )

Definition at line 1358 of file qabstractitemview.cpp.

References setHorizontalScrollMode(), and QStyle::SH_ItemView_ScrollMode.

Referenced by event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetVerticalScrollMode()

void QAbstractItemView::resetVerticalScrollMode ( )

Definition at line 1321 of file qabstractitemview.cpp.

References setVerticalScrollMode(), and QStyle::SH_ItemView_ScrollMode.

Referenced by event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resizeEvent()

void QAbstractItemView::resizeEvent ( QResizeEvent * event)
overrideprotected

This function is called with the given event when a resize event is sent to the widget.

See also
QWidget::resizeEvent()

Definition at line 2583 of file qabstractitemview.cpp.

References updateGeometries().

Referenced by QListView::resizeEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rootIndex()

QModelIndex QAbstractItemView::rootIndex ( ) const

Returns the model index of the model's root item.

The root item is the parent item to the view's toplevel items. The root can be invalid.

See also
setRootIndex()

Definition at line 1189 of file qabstractitemview.cpp.

Referenced by QCommonListViewBase::appendHiddenRow(), QTreeView::moveCursor(), QCommonListViewBase::removeHiddenRow(), and QTableWidget::setRangeSelected().

+ Here is the caller graph for this function:

◆ rowsAboutToBeRemoved

void QAbstractItemView::rowsAboutToBeRemoved ( const QModelIndex & parent,
int start,
int end )
protectedvirtualslot

This slot is called when rows are about to be removed.

The deleted rows are those under the given parent from start to end inclusive.

See also
rowsInserted()

Reimplemented in QListView, and QTreeView.

Definition at line 3474 of file qabstractitemview.cpp.

References child, CollapsingState, QModelIndex::column(), currentIndex(), d, i, info, isIndexHidden(), QModelIndex::isValid(), QHash< QWidget *, QPersistentModelIndex >::iterator, next, QModelIndex::parent(), qWarning, QModelIndex::row(), setCurrentIndex(), setState(), and SingleSelection.

Referenced by QListView::rowsAboutToBeRemoved(), QTreeView::rowsAboutToBeRemoved(), and setModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rowsInserted

void QAbstractItemView::rowsInserted ( const QModelIndex & parent,
int start,
int end )
protectedvirtualslot

This slot is called when rows are inserted.

The new rows are those under the given parent from start to end inclusive. The base class implementation calls fetchMore() on the model to check for more data.

See also
rowsAboutToBeRemoved()

Reimplemented in QColumnView, QHeaderView, QListView, and QTreeView.

Definition at line 3460 of file qabstractitemview.cpp.

References isVisible(), and updateEditorGeometries().

Referenced by QListView::rowsInserted(), QTreeView::rowsInserted(), and setModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scheduleDelayedItemsLayout()

void QAbstractItemView::scheduleDelayedItemsLayout ( )
protected

Schedules a layout of the items in the view to be executed when the event processing starts.

Even if scheduleDelayedItemsLayout() is called multiple times before events are processed, the view will only do the layout once.

See also
executeDelayedItemsLayout()

Definition at line 3949 of file qabstractitemview.cpp.

References d.

Referenced by QTreeWidgetItem::setChildIndicatorPolicy().

+ Here is the caller graph for this function:

◆ scrollDirtyRegion()

void QAbstractItemView::scrollDirtyRegion ( int dx,
int dy )
protected

Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite direction.

You only need to call this function if you are implementing a scrolling viewport in your view subclass.

If you implement scrollContentsBy() in a subclass of QAbstractItemView, call this function before you call QWidget::scroll() on the viewport. Alternatively, just call update().

See also
scrollContentsBy(), dirtyRegionOffset(), setDirtyRegion()

Definition at line 3993 of file qabstractitemview.cpp.

References d.

Referenced by QColumnViewPreviewColumn::scrollContentsBy().

+ Here is the caller graph for this function:

◆ scrollTo()

void QAbstractItemView::scrollTo ( const QModelIndex & index,
ScrollHint hint = EnsureVisible )
pure virtual

Scrolls the view if necessary to ensure that the item at index is visible.

The view will try to position the item according to the given hint.

In the base class this is a pure virtual function.

Implemented in QColumnViewPreviewColumn, QHeaderView, QColumnView, QListView, QTableView, and QTreeView.

Referenced by currentChanged(), event(), QCompleterPrivate::setCurrentIndex(), setVerticalScrollMode(), QComboBox::showPopup(), and timerEvent().

+ Here is the caller graph for this function:

◆ scrollToBottom

void QAbstractItemView::scrollToBottom ( )
slot
Since
4.1

Scrolls the view to the bottom.

See also
scrollTo(), scrollToTop()

Definition at line 3364 of file qabstractitemview.cpp.

References d, and updateGeometries().

+ Here is the call graph for this function:

◆ scrollToTop

void QAbstractItemView::scrollToTop ( )
slot
Since
4.1

Scrolls the view to the top.

See also
scrollTo(), scrollToBottom()

Definition at line 3352 of file qabstractitemview.cpp.

Referenced by QCompleterPrivate::setCurrentIndex(), and QComboBox::showPopup().

+ Here is the caller graph for this function:

◆ selectAll

void QAbstractItemView::selectAll ( )
virtualslot

Selects all items in the view.

This function will use the selection behavior set on the view when selecting.

See also
setSelection(), selectedIndexes(), clearSelection()

Reimplemented in QColumnView, and QTreeView.

Definition at line 1201 of file qabstractitemview.cpp.

References QItemSelectionModel::ClearAndSelect, ContiguousSelection, d, ExtendedSelection, MultiSelection, NoSelection, selectionCommand(), and SingleSelection.

Referenced by QTableViewPrivate::init(), and keyPressEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selectedIndexes()

QModelIndexList QAbstractItemView::selectedIndexes ( ) const
protectedvirtual

This convenience function returns a list of all selected and non-hidden item indexes in the view.

The list contains no duplicates, and is not sorted.

See also
QItemSelectionModel::selectedIndexes()

Reimplemented in QListView, QTableView, and QTreeView.

Definition at line 2722 of file qabstractitemview.cpp.

References d, isIndexHidden(), and QList< T >::removeIf().

+ Here is the call graph for this function:

◆ selectionBehavior()

QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior ( ) const

Definition at line 1078 of file qabstractitemview.cpp.

References d.

◆ selectionChanged

void QAbstractItemView::selectionChanged ( const QItemSelection & selected,
const QItemSelection & deselected )
protectedvirtualslot

This slot is called when the selection is changed.

The previous selection (which may be empty), is specified by deselected, and the new selection by selected.

See also
setSelection()

Reimplemented in QListView, QTableView, and QTreeView.

Definition at line 3785 of file qabstractitemview.cpp.

References d, isVisible(), and visualRegionForSelection().

Referenced by QListView::selectionChanged(), QTableView::selectionChanged(), QTreeView::selectionChanged(), and setSelectionModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selectionCommand()

QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand ( const QModelIndex & index,
const QEvent * event = nullptr ) const
protectedvirtual

Returns the SelectionFlags to be used when updating a selection model for the specified index.

The result depends on the current selectionMode(), and on the user input event event, which can be \nullptr.

Reimplement this function to define your own selection behavior.

See also
setSelection()

Definition at line 4125 of file qabstractitemview.cpp.

References QItemSelectionModel::ClearAndSelect, ContiguousSelection, Qt::ControlModifier, d, QItemSelectionModel::Deselect, ExtendedSelection, QEvent::KeyPress, QEvent::MouseButtonPress, QEvent::MouseButtonRelease, MultiSelection, Qt::NoModifier, NoSelection, QItemSelectionModel::NoUpdate, Q_FALLTHROUGH, and SingleSelection.

Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), selectAll(), and setCurrentIndex().

+ Here is the caller graph for this function:

◆ selectionMode()

QAbstractItemView::SelectionMode QAbstractItemView::selectionMode ( ) const

Definition at line 1056 of file qabstractitemview.cpp.

References d.

◆ selectionModel()

QItemSelectionModel * QAbstractItemView::selectionModel ( ) const

◆ setAlternatingRowColors()

void QAbstractItemView::setAlternatingRowColors ( bool enable)

Definition at line 1603 of file qabstractitemview.cpp.

References d, and isVisible().

+ Here is the call graph for this function:

◆ setAutoScroll()

void QAbstractItemView::setAutoScroll ( bool enable)

Definition at line 1414 of file qabstractitemview.cpp.

References d.

◆ setAutoScrollMargin()

void QAbstractItemView::setAutoScrollMargin ( int margin)

Definition at line 1434 of file qabstractitemview.cpp.

References d.

◆ setCurrentIndex

void QAbstractItemView::setCurrentIndex ( const QModelIndex & index)
slot

Sets the current item to be the item at index.

Unless the current selection mode is \l{QAbstractItemView::}{NoSelection}, the item is also selected. Note that this function also updates the starting position for any new selections the user performs.

To set an item as the current item without selecting it, call

{selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);}

See also
currentIndex(), currentChanged(), selectionMode

Definition at line 1098 of file qabstractitemview.cpp.

References QItemSelectionModel::Current, d, and selectionCommand().

Referenced by QInputDialogPrivate::ensureListView(), QComboBoxPrivateContainer::eventFilter(), eventFilter(), keyboardSearch(), QTreeView::keyboardSearch(), rowsAboutToBeRemoved(), QTableWidget::setCurrentCell(), QFontListView::setCurrentItem(), QTableWidget::setCurrentItem(), QTreeWidget::setCurrentItem(), QSidebar::setModelAndUrls(), and QQuickFontDialogImplAttached::updateFamilies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDirtyRegion()

void QAbstractItemView::setDirtyRegion ( const QRegion & region)
protected
Since
4.1

Marks the given region as dirty and schedules it to be updated. You only need to call this function if you are implementing your own view subclass.

See also
scrollDirtyRegion(), dirtyRegionOffset()

Definition at line 3977 of file qabstractitemview.cpp.

References d.

◆ setEditTriggers()

void QAbstractItemView::setEditTriggers ( EditTriggers triggers)

Definition at line 1277 of file qabstractitemview.cpp.

References d.

Referenced by QFontListView::QFontListView(), QInputDialogPrivate::ensureListView(), QCompleter::popup(), QFileDialogListView::setFileDialogPrivate(), QFileDialogTreeView::setFileDialogPrivate(), and QComboBoxPrivateContainer::setItemView().

+ Here is the caller graph for this function:

◆ setHorizontalScrollMode()

void QAbstractItemView::setHorizontalScrollMode ( ScrollMode mode)

Definition at line 1338 of file qabstractitemview.cpp.

References d, ScrollPerItem, and updateGeometries().

Referenced by resetHorizontalScrollMode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIconSize()

void QAbstractItemView::setIconSize ( const QSize & size)

Definition at line 1624 of file qabstractitemview.cpp.

References d, emit, and iconSizeChanged().

Referenced by QComboBox::setIconSize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIndexWidget()

void QAbstractItemView::setIndexWidget ( const QModelIndex & index,
QWidget * widget )
Since
4.1

Sets the given widget on the item at the given index, passing the ownership of the widget to the viewport.

If index is invalid (e.g., if you pass the root index), this function will do nothing.

The given widget's \l{QWidget}{autoFillBackground} property must be set to true, otherwise the widget's background will be transparent, showing both the model data and the item at the given index.

If index widget A is replaced with index widget B, index widget A will be deleted. For example, in the code snippet below, the QLineEdit object will be deleted.

...
setIndexWidget(index, new QTextEdit);

This function should only be used to display static content within the visible area corresponding to an item of data. If you want to display custom dynamic content or implement a custom editor widget, subclass QStyledItemDelegate instead.

See also
{Delegate Classes}

Definition at line 3303 of file qabstractitemview.cpp.

References d, dataChanged(), indexWidget(), QObject::installEventFilter(), QWidget::setGeometry(), QWidget::setParent(), QWidget::show(), viewport(), visualRect(), and widget.

Referenced by QTableWidget::setCellWidget(), QListWidget::setItemWidget(), and QTreeWidget::setItemWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setItemDelegate()

void QAbstractItemView::setItemDelegate ( QAbstractItemDelegate * delegate)

Sets the item delegate for this view and its model to delegate.

This is useful if you want complete control over the editing and display of items.

Any existing delegate will be removed, but not deleted. QAbstractItemView does not take ownership of delegate.

Warning
You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()} signal, and attempt to access, modify or close an editor that has already been closed.
See also
itemDelegate()

Definition at line 856 of file qabstractitemview.cpp.

References d, and viewport().

Referenced by QComboBox::setItemDelegate(), and QSidebar::setModelAndUrls().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setItemDelegateForColumn()

void QAbstractItemView::setItemDelegateForColumn ( int column,
QAbstractItemDelegate * delegate )
Since
4.2

Sets the given item delegate used by this view and model for the given column. All items on column will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate()).

Any existing column delegate for column will be removed, but not deleted. QAbstractItemView does not take ownership of delegate.

Note
If a delegate has been assigned to both a row and a column, the row delegate will take precedence and manage the intersecting cell index.
Warning
You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()} signal, and attempt to access, modify or close an editor that has already been closed.
See also
itemDelegateForColumn(), setItemDelegateForRow(), itemDelegate()

Definition at line 987 of file qabstractitemview.cpp.

References d, and viewport().

+ Here is the call graph for this function:

◆ setItemDelegateForRow()

void QAbstractItemView::setItemDelegateForRow ( int row,
QAbstractItemDelegate * delegate )
Since
4.2

Sets the given item delegate used by this view and model for the given row. All items on row will be drawn and managed by delegate instead of using the default delegate (i.e., itemDelegate()).

Any existing row delegate for row will be removed, but not deleted. QAbstractItemView does not take ownership of delegate.

Note
If a delegate has been assigned to both a row and a column, the row delegate (i.e., this delegate) will take precedence and manage the intersecting cell index.
Warning
You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the \l{QAbstractItemDelegate::}{closeEditor()} signal, and attempt to access, modify or close an editor that has already been closed.
See also
itemDelegateForRow(), setItemDelegateForColumn(), itemDelegate()

Definition at line 935 of file qabstractitemview.cpp.

References d, and viewport().

+ Here is the call graph for this function:

◆ setModel()

void QAbstractItemView::setModel ( QAbstractItemModel * model)
virtual

Sets the model for the view to present.

This function will create and set a new selection model, replacing any model that was previously set with setSelectionModel(). However, the old selection model will not be deleted as it may be shared between several views. We recommend that you delete the old selection model if it is no longer required. This is done with the following code:

QItemSelectionModel *m = view->selectionModel();
view->setModel(new model);
delete m;
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
const GLfloat * m
QSqlQueryModel * model
[16]
setIndexWidget(index, new QLineEdit)
[0]

If both the old model and the old selection model do not have parents, or if their parents are long-lived objects, it may be preferable to call their deleteLater() functions to explicitly delete them.

The view {does not} take ownership of the model unless it is the model's parent object because the model may be shared between many different views.

See also
selectionModel(), setSelectionModel()

Reimplemented in QColumnView, QHeaderView, QListWidget, QTableView, QTableWidget, QTreeView, and QTreeWidget.

Definition at line 715 of file qabstractitemview.cpp.

References QAbstractItemModel::columnsAboutToBeRemoved(), QAbstractItemViewPrivate::columnsAboutToBeRemoved(), QAbstractItemModel::columnsInserted(), QAbstractItemViewPrivate::columnsInserted(), QAbstractItemViewPrivate::columnsMoved(), QAbstractItemModel::columnsMoved(), QAbstractItemModel::columnsRemoved(), QAbstractItemViewPrivate::columnsRemoved(), QObject::connect(), QObjectPrivate::connect(), connect(), connection, d, QAbstractItemModel::dataChanged(), dataChanged(), QObject::deleteLater(), QObject::destroyed(), disconnect(), QAbstractItemViewPrivate::headerDataChanged(), QAbstractItemModel::headerDataChanged(), QAbstractItemViewPrivate::layoutChanged(), QAbstractItemModel::layoutChanged(), model(), QAbstractItemViewPrivate::modelDestroyed(), QAbstractItemModel::modelReset(), reset(), QAbstractItemModel::rowsAboutToBeRemoved(), rowsAboutToBeRemoved(), QAbstractItemModel::rowsInserted(), rowsInserted(), QAbstractItemViewPrivate::rowsInserted(), QAbstractItemViewPrivate::rowsMoved(), QAbstractItemModel::rowsMoved(), QAbstractItemModel::rowsRemoved(), QAbstractItemViewPrivate::rowsRemoved(), setSelectionModel(), and QAbstractItemModelPrivate::staticEmptyModel().

Referenced by QFontListView::QFontListView(), QInputDialogPrivate::ensureListView(), main(), QHeaderView::setModel(), QTableView::setModel(), QTreeView::setModel(), QSidebar::setModelAndUrls(), QCompleter::setPopup(), QComboBox::setView(), QQuickFontDialogImplAttached::updateFamilies(), and QComboBoxPrivate::viewContainer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRootIndex

void QAbstractItemView::setRootIndex ( const QModelIndex & index)
virtualslot

Sets the root item to the item at the given index.

See also
rootIndex()

Reimplemented in QColumnView, QListView, QTableView, and QTreeView.

Definition at line 1165 of file qabstractitemview.cpp.

References d, Q_UNLIKELY, and qWarning.

Referenced by reset(), QListView::setRootIndex(), QTableView::setRootIndex(), QTreeView::setRootIndex(), and QComboBox::setRootModelIndex().

+ Here is the caller graph for this function:

◆ setSelection()

void QAbstractItemView::setSelection ( const QRect & rect,
QItemSelectionModel::SelectionFlags flags )
protectedpure virtual

Applies the selection flags to the items in or touched by the rectangle, rect.

When implementing your own itemview setSelection should call selectionModel()->select(selection, flags) where selection is either an empty QModelIndex or a QItemSelection that contains all items that are contained in rect.

See also
selectionCommand(), selectedIndexes()

Implemented in QColumnViewPreviewColumn, QColumnView, QListView, QTableView, QTreeView, and QHeaderView.

Referenced by keyPressEvent(), mouseMoveEvent(), and mousePressEvent().

+ Here is the caller graph for this function:

◆ setSelectionBehavior()

void QAbstractItemView::setSelectionBehavior ( QAbstractItemView::SelectionBehavior behavior)

Definition at line 1072 of file qabstractitemview.cpp.

References d.

Referenced by QCompleter::popup(), QFileDialogListView::setFileDialogPrivate(), and QFileDialogTreeView::setFileDialogPrivate().

+ Here is the caller graph for this function:

◆ setSelectionMode()

void QAbstractItemView::setSelectionMode ( QAbstractItemView::SelectionMode mode)

Definition at line 1050 of file qabstractitemview.cpp.

References d.

Referenced by QListView::QListView(), QListView::QListView(), QInputDialogPrivate::ensureListView(), QCompleter::popup(), and QComboBoxPrivateContainer::setItemView().

+ Here is the caller graph for this function:

◆ setSelectionModel()

void QAbstractItemView::setSelectionModel ( QItemSelectionModel * selectionModel)
virtual

Sets the current selection model to the given selectionModel.

Note that, if you call setModel() after this function, the given selectionModel will be replaced by one created by the view.

Note
It is up to the application to delete the old selection model if it is no longer needed; i.e., if it is not being used by other views. This will happen automatically when its parent object is deleted. However, if it does not have a parent, or if the parent is a long-lived object, it may be preferable to call its deleteLater() function to explicitly delete it.
See also
selectionModel(), setModel(), clearSelection()

Reimplemented in QColumnView, QListWidget, QTableView, QTreeView, and QTreeWidget.

Definition at line 790 of file qabstractitemview.cpp.

References connect(), QItemSelectionModel::currentChanged(), currentChanged(), d, disconnect(), QItemSelectionModel::model, Q_ASSERT, Q_UNLIKELY, qWarning, QItemSelectionModel::selectionChanged(), selectionChanged(), and selectionModel().

Referenced by setModel(), QListWidget::setSelectionModel(), QTableView::setSelectionModel(), and QTreeView::setSelectionModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setState()

void QAbstractItemView::setState ( State state)
protected

Sets the item view's state to the given state.

See also
state()

Definition at line 3934 of file qabstractitemview.cpp.

References d, and state().

Referenced by closeEditor(), QListView::doItemsLayout(), editorDestroyed(), mouseMoveEvent(), mouseReleaseEvent(), QTreeView::mouseReleaseEvent(), reset(), and rowsAboutToBeRemoved().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTabKeyNavigation()

void QAbstractItemView::setTabKeyNavigation ( bool enable)

Definition at line 1451 of file qabstractitemview.cpp.

References d.

Referenced by QtPrivate::QCalendarView::QCalendarView().

+ Here is the caller graph for this function:

◆ setTextElideMode()

void QAbstractItemView::setTextElideMode ( Qt::TextElideMode mode)

Definition at line 1647 of file qabstractitemview.cpp.

References d.

Referenced by QFileDialogTreeView::setFileDialogPrivate(), and QComboBoxPrivate::viewContainer().

+ Here is the caller graph for this function:

◆ setVerticalScrollMode()

void QAbstractItemView::setVerticalScrollMode ( ScrollMode mode)

Definition at line 1299 of file qabstractitemview.cpp.

References d, indexAt(), PositionAtTop, ScrollPerItem, scrollTo(), and updateGeometries().

Referenced by resetVerticalScrollMode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeHintForColumn()

int QAbstractItemView::sizeHintForColumn ( int column) const
virtual

Returns the width size hint for the specified column or -1 if there is no model.

This function is used in views with a horizontal header to find the size hint for a header section based on the contents of the given column.

See also
sizeHintForRow()

Reimplemented in QTableView, and QTreeView.

Definition at line 3203 of file qabstractitemview.cpp.

References d, initViewItemOption(), itemDelegateForIndex(), QModelIndex::model(), qMax(), and QAbstractItemDelegate::sizeHint().

+ Here is the call graph for this function:

◆ sizeHintForIndex()

QSize QAbstractItemView::sizeHintForIndex ( const QModelIndex & index) const

Returns the size hint for the item with the specified index or an invalid size for invalid indexes.

See also
sizeHintForRow(), sizeHintForColumn()

Definition at line 3145 of file qabstractitemview.cpp.

References d, initViewItemOption(), itemDelegateForIndex(), and QAbstractItemDelegate::sizeHint().

Referenced by QSidebar::sizeHint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeHintForRow()

int QAbstractItemView::sizeHintForRow ( int row) const
virtual

Returns the height size hint for the specified row or -1 if there is no model.

The returned height is calculated using the size hints of the given row's items, i.e. the returned value is the maximum height among the items. Note that to control the height of a row, you must reimplement the QAbstractItemDelegate::sizeHint() function.

This function is used in views with a vertical header to find the size hint for a header section based on the contents of the given row.

See also
sizeHintForColumn()

Reimplemented in QTableView.

Definition at line 3172 of file qabstractitemview.cpp.

References d, initViewItemOption(), itemDelegateForIndex(), QModelIndex::model(), qMax(), and QAbstractItemDelegate::sizeHint().

Referenced by QTreeView::scrollContentsBy(), QCompleterPrivate::showPopup(), QFileDialogListView::sizeHint(), and QFileDialogTreeView::sizeHint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startAutoScroll()

void QAbstractItemView::startAutoScroll ( )
protected

Definition at line 4017 of file qabstractitemview.cpp.

Referenced by mouseMoveEvent().

+ Here is the caller graph for this function:

◆ state()

◆ stopAutoScroll()

void QAbstractItemView::stopAutoScroll ( )
protected

Definition at line 4025 of file qabstractitemview.cpp.

Referenced by doAutoScroll().

+ Here is the caller graph for this function:

◆ tabKeyNavigation()

bool QAbstractItemView::tabKeyNavigation ( ) const

Definition at line 1457 of file qabstractitemview.cpp.

References d.

◆ textElideMode()

Qt::TextElideMode QAbstractItemView::textElideMode ( ) const

Definition at line 1653 of file qabstractitemview.cpp.

◆ timerEvent()

void QAbstractItemView::timerEvent ( QTimerEvent * event)
overrideprotected

This function is called with the given event when a timer event is sent to the widget.

See also
QObject::timerEvent()

Definition at line 2595 of file qabstractitemview.cpp.

References currentIndex(), d, doAutoScroll(), doItemsLayout(), edit, EditingState, QModelIndex::isValid(), isVisible(), reset(), and scrollTo().

Referenced by QListView::timerEvent(), QTableView::timerEvent(), and QTreeView::timerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update

void QAbstractItemView::update ( const QModelIndex & index)
slot
Since
4.3

Updates the area occupied by the given index.

Definition at line 3380 of file qabstractitemview.cpp.

References d, and rect.

Referenced by currentChanged(), dataChanged(), edit(), mouseReleaseEvent(), QTableView::scrollTo(), and QIconModeViewBase::setPositionForIndex().

+ Here is the caller graph for this function:

◆ updateEditorData

void QAbstractItemView::updateEditorData ( )
protectedvirtualslot

Updates the data shown in the open editor widgets in the view.

Definition at line 2813 of file qabstractitemview.cpp.

References d.

◆ updateEditorGeometries

void QAbstractItemView::updateEditorGeometries ( )
protectedvirtualslot

Updates the geometry of the open editor widgets in the view.

Definition at line 2823 of file qabstractitemview.cpp.

References QSet< T >::begin(), d, QSet< T >::end(), QSet< T >::erase(), i, initViewItemOption(), it, itemDelegateForIndex(), QHash< QWidget *, QPersistentModelIndex >::iterator, QSet< T >::remove(), QAbstractItemDelegate::updateEditorGeometry(), and visualRect().

Referenced by QTreeView::columnMoved(), rowsInserted(), QTableView::timerEvent(), and updateGeometries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateGeometries

void QAbstractItemView::updateGeometries ( )
protectedvirtualslot
Since
4.4

Updates the geometry of the child widgets of the view.

Reimplemented in QHeaderView, QListView, QTableView, and QTreeView.

Definition at line 2874 of file qabstractitemview.cpp.

References d, and updateEditorGeometries().

Referenced by doItemsLayout(), event(), resizeEvent(), scrollToBottom(), setHorizontalScrollMode(), setVerticalScrollMode(), QListView::updateGeometries(), QTableView::updateGeometries(), and QTreeView::updateGeometries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verticalOffset()

int QAbstractItemView::verticalOffset ( ) const
protectedpure virtual

Returns the vertical offset of the view.

In the base class this is a pure virtual function.

See also
horizontalOffset()

Implemented in QColumnView, QColumnViewPreviewColumn, QHeaderView, QListView, QTableView, and QTreeView.

◆ verticalScrollbarAction

void QAbstractItemView::verticalScrollbarAction ( int action)
protectedvirtualslot

Reimplemented in QTableView.

Definition at line 2911 of file qabstractitemview.cpp.

Referenced by QAbstractItemViewPrivate::init(), and QTableView::verticalScrollbarAction().

+ Here is the caller graph for this function:

◆ verticalScrollbarValueChanged

void QAbstractItemView::verticalScrollbarValueChanged ( int value)
protectedvirtualslot

Definition at line 2885 of file qabstractitemview.cpp.

References contains(), d, QCursor::pos(), rect, and viewport().

Referenced by QAbstractItemViewPrivate::init(), and QTreeView::verticalScrollbarValueChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verticalScrollMode()

QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode ( ) const

Definition at line 1315 of file qabstractitemview.cpp.

References d.

◆ viewportEntered

void QAbstractItemView::viewportEntered ( )
signal

This signal is emitted when the mouse cursor enters the viewport.

Mouse tracking needs to be enabled for this feature to work.

See also
entered()

◆ viewportEvent()

bool QAbstractItemView::viewportEvent ( QEvent * event)
overrideprotected

This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::ToolTip,or a QEvent::WhatsThis.

It passes all other events on to its base class viewportEvent() handler.

Returns true if event has been recognized and processed; otherwise, returns false.

Definition at line 1731 of file qabstractitemview.cpp.

References QObjectPrivate::connect(), currentIndex(), d, QEvent::Enter, executeDelayedItemsLayout(), QEvent::FontChange, QAbstractItemDelegate::helpEvent(), QEvent::HoverEnter, QEvent::HoverLeave, QEvent::HoverMove, indexAt(), initViewItemOption(), itemDelegateForIndex(), QEvent::Leave, QEvent::Paint, position(), QEvent::QueryWhatsThis, QScroller::scroller(), QAbstractItemViewPrivate::scrollerStateChanged(), QEvent::ScrollPrepare, QCoreApplication::sendEvent(), QStyle::State_HasFocus, QStyle::State_None, QScroller::stateChanged(), QEvent::ToolTip, Qt::UniqueConnection, visualRect(), QEvent::WhatsThis, QEvent::WindowActivate, and QEvent::WindowDeactivate.

Referenced by QHeaderView::viewportEvent(), and QTreeView::viewportEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewportSizeHint()

QSize QAbstractItemView::viewportSizeHint ( ) const
overrideprotected
Since
5.2 \reimp

Definition at line 1467 of file qabstractitemview.cpp.

Referenced by QListView::viewportSizeHint(), and QTreeView::viewportSizeHint().

+ Here is the caller graph for this function:

◆ visualRect()

QRect QAbstractItemView::visualRect ( const QModelIndex & index) const
pure virtual

Returns the rectangle on the viewport occupied by the item at index.

If your item is displayed in several areas then visualRect should return the primary area that contains index and not the complete area that index might encompasses, touch or cause drawing.

In the base class this is a pure virtual function.

See also
indexAt(), visualRegionForSelection()

Implemented in QColumnViewPreviewColumn, QColumnView, QHeaderView, QListView, QTableView, and QTreeView.

Referenced by inputMethodQuery(), keyPressEvent(), mousePressEvent(), openPersistentEditor(), setIndexWidget(), QComboBox::showPopup(), updateEditorGeometries(), and viewportEvent().

+ Here is the caller graph for this function:

◆ visualRegionForSelection()

QRegion QAbstractItemView::visualRegionForSelection ( const QItemSelection & selection) const
protectedpure virtual

Returns the region from the viewport of the items in the given selection.

In the base class this is a pure virtual function.

See also
visualRect(), selectedIndexes()

Implemented in QColumnViewPreviewColumn, QColumnView, QHeaderView, QListView, QTableView, and QTreeView.

Referenced by selectionChanged().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ ::tst_QAbstractItemView

friend class ::tst_QAbstractItemView
friend

Definition at line 330 of file qabstractitemview.h.

◆ ::tst_QTreeView

friend class ::tst_QTreeView
friend

Definition at line 331 of file qabstractitemview.h.

◆ QAbstractSlider

friend class QAbstractSlider
friend

Definition at line 335 of file qabstractitemview.h.

◆ QListModeViewBase

friend class QListModeViewBase
friend

Definition at line 333 of file qabstractitemview.h.

Referenced by QListView::setViewMode().

◆ QListViewPrivate

friend class QListViewPrivate
friend

Definition at line 334 of file qabstractitemview.h.

◆ QTreeViewPrivate

friend class QTreeViewPrivate
friend

Definition at line 332 of file qabstractitemview.h.

Property Documentation

◆ alternatingRowColors

QAbstractItemView::alternatingRowColors
readwrite

whether to draw the background using alternating colors

If this property is true, the item background will be drawn using QPalette::Base and QPalette::AlternateBase; otherwise the background will be drawn using the QPalette::Base color.

By default, this property is false.

Definition at line 39 of file qabstractitemview.h.

◆ autoScroll

QAbstractItemView::autoScroll
readwrite

whether autoscrolling in drag move events is enabled

If this property is set to true (the default), the QAbstractItemView automatically scrolls the contents of the view if the user drags within 16 pixels of the viewport edge. If the current item changes, then the view will scroll automatically to ensure that the current item is fully visible.

This property only works if the viewport accepts drops. Autoscroll is switched off by setting this property to false.

Definition at line 28 of file qabstractitemview.h.

Referenced by focusInEvent(), and mousePressEvent().

◆ autoScrollMargin

QAbstractItemView::autoScrollMargin
readwrite

the size of the area when auto scrolling is triggered

Since
4.4

This property controls the size of the area at the edge of the viewport that triggers autoscrolling. The default value is 16 pixels.

Definition at line 29 of file qabstractitemview.h.

◆ editTriggers

QAbstractItemView::editTriggers
readwrite

which actions will initiate item editing

This property is a selection of flags defined by \l{EditTrigger}, combined using the OR operator. The view will only initiate the editing of an item if the action performed is set in this property.

Definition at line 30 of file qabstractitemview.h.

Referenced by closeEditor().

◆ horizontalScrollMode

QAbstractItemView::horizontalScrollMode
readwrite

how the view scrolls its contents in the horizontal direction

Since
4.2

This property controls how the view scroll its contents horizontally. Scrolling can be done either per pixel or per item. Its default value comes from the style via the QStyle::SH_ItemView_ScrollMode style hint.

Definition at line 47 of file qabstractitemview.h.

Referenced by QTableView::columnCountChanged(), QCommonListViewBase::horizontalScrollMode(), QTableView::scrollContentsBy(), QTreeView::scrollContentsBy(), QTableView::scrollTo(), and QTableView::updateGeometries().

◆ iconSize

QAbstractItemView::iconSize
readwrite

the size of items' icons

Setting this property when the view is visible will cause the items to be laid out again.

Definition at line 43 of file qabstractitemview.h.

◆ selectionBehavior

QAbstractItemView::selectionBehavior
readwrite

which selection behavior the view uses

This property holds whether selections are done in terms of single items, rows or columns.

See also
SelectionMode, SelectionBehavior

Definition at line 41 of file qabstractitemview.h.

Referenced by QTreeView::drawBranches(), and QTreeView::drawRow().

◆ selectionMode

QAbstractItemView::selectionMode
readwrite

which selection mode the view operates in

This property controls whether the user can select one or many items and, in many-item selections, whether the selection must be a continuous range of items.

See also
SelectionMode, SelectionBehavior

Definition at line 40 of file qabstractitemview.h.

Referenced by keyPressEvent().

◆ tabKeyNavigation

QAbstractItemView::tabKeyNavigation
readwrite

whether item navigation with tab and backtab is enabled.

Definition at line 31 of file qabstractitemview.h.

◆ textElideMode

QAbstractItemView::textElideMode
readwrite

the position of the "..." in elided text.

The default value for all item views is Qt::ElideRight.

Definition at line 44 of file qabstractitemview.h.

◆ verticalScrollMode

QAbstractItemView::verticalScrollMode
readwrite

how the view scrolls its contents in the vertical direction

Since
4.2

This property controls how the view scroll its contents vertically. Scrolling can be done either per pixel or per item. Its default value comes from the style via the QStyle::SH_ItemView_ScrollMode style hint.

Definition at line 45 of file qabstractitemview.h.

Referenced by QTreeView::drawBranches(), QTableView::scrollContentsBy(), QTreeView::scrollContentsBy(), QTableView::scrollTo(), QTreeView::scrollTo(), QTableView::updateGeometries(), and QCommonListViewBase::verticalScrollMode().


The documentation for this class was generated from the following files: