QtBase
v6.3.1
|
The QAbstractItemView class provides the basic functionality for item view classes. More...
#include <qabstractitemview.h>
Public Types | |
enum | SelectionMode { NoSelection , SingleSelection , MultiSelection , ExtendedSelection , ContiguousSelection } |
enum | SelectionBehavior { SelectItems , SelectRows , SelectColumns } |
enum | ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter } |
enum | EditTrigger { NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 , EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31 } |
enum | ScrollMode { ScrollPerItem , ScrollPerPixel } |
Public Slots | |
virtual void | reset () |
virtual void | setRootIndex (const QModelIndex &index) |
virtual void | doItemsLayout () |
virtual void | selectAll () |
void | edit (const QModelIndex &index) |
void | clearSelection () |
void | setCurrentIndex (const QModelIndex &index) |
void | scrollToTop () |
void | scrollToBottom () |
void | update (const QModelIndex &index) |
Signals | |
void | pressed (const QModelIndex &index) |
void | clicked (const QModelIndex &index) |
void | doubleClicked (const QModelIndex &index) |
void | activated (const QModelIndex &index) |
void | entered (const QModelIndex &index) |
void | viewportEntered () |
void | iconSizeChanged (const QSize &size) |
Protected Types | |
enum | CursorAction { MoveUp , MoveDown , MoveLeft , MoveRight , MoveHome , MoveEnd , MovePageUp , MovePageDown , MoveNext , MovePrevious } |
enum | State { NoState , DraggingState , DragSelectingState , EditingState , ExpandingState , CollapsingState , AnimatingState } |
Protected Slots | |
virtual void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >()) |
virtual void | rowsInserted (const QModelIndex &parent, int start, int end) |
virtual void | rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) |
virtual void | selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) |
virtual void | currentChanged (const QModelIndex ¤t, const QModelIndex &previous) |
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) |
virtual void | commitData (QWidget *editor) |
virtual void | editorDestroyed (QObject *editor) |
Properties | |
bool | autoScroll |
whether autoscrolling in drag move events is enabled More... | |
int | autoScrollMargin |
the size of the area when auto scrolling is triggered More... | |
EditTriggers | editTriggers |
which actions will initiate item editing More... | |
bool | tabKeyNavigation |
whether item navigation with tab and backtab is enabled. More... | |
bool | alternatingRowColors |
whether to draw the background using alternating colors More... | |
SelectionMode | selectionMode |
which selection mode the view operates in More... | |
SelectionBehavior | selectionBehavior |
which selection behavior the view uses More... | |
QSize | iconSize |
the size of items' icons More... | |
Qt::TextElideMode | textElideMode |
the position of the "..." in elided text. More... | |
ScrollMode | verticalScrollMode |
how the view scrolls its contents in the vertical direction More... | |
ScrollMode | horizontalScrollMode |
how the view scrolls its contents in the horizontal direction More... | |
Friends | |
class | QTreeViewPrivate |
class | QListModeViewBase |
class | QListViewPrivate |
class | QAbstractSlider |
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
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:
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.
Definition at line 61 of file qabstractitemview.h.
|
protected |
This enum describes the different ways to navigate between items,
\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 284 of file qabstractitemview.h.
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 111 of file qabstractitemview.h.
\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 103 of file qabstractitemview.h.
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 124 of file qabstractitemview.h.
\value SelectItems Selecting single items. \value SelectRows Selecting only rows. \value SelectColumns Selecting only columns.
Enumerator | |
---|---|
SelectItems | |
SelectRows | |
SelectColumns |
Definition at line 96 of file qabstractitemview.h.
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 87 of file qabstractitemview.h.
|
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 310 of file qabstractitemview.h.
Constructs an abstract item view with the given parent.
Definition at line 631 of file qabstractitemview.cpp.
QAbstractItemView::~QAbstractItemView | ( | ) |
Destroys the view.
Definition at line 649 of file qabstractitemview.cpp.
|
protected |
Definition at line 640 of file qabstractitemview.cpp.
|
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.
bool QAbstractItemView::alternatingRowColors | ( | ) | const |
Definition at line 1614 of file qabstractitemview.cpp.
int QAbstractItemView::autoScrollMargin | ( | ) | const |
Definition at line 1443 of file qabstractitemview.cpp.
|
slot |
Deselects all selected items. The current index will not be changed.
Definition at line 1250 of file qabstractitemview.cpp.
|
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.
|
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.
Definition at line 2930 of file qabstractitemview.cpp.
void QAbstractItemView::closePersistentEditor | ( | const QModelIndex & | index | ) |
Closes the persistent editor for the item at the given index.
Definition at line 3236 of file qabstractitemview.cpp.
Commit the data in the editor to the model.
Definition at line 3012 of file qabstractitemview.cpp.
|
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 QTreeView, QTableView, QListView, QColumnView, QFontListView, and QHeaderView.
Definition at line 3775 of file qabstractitemview.cpp.
QModelIndex QAbstractItemView::currentIndex | ( | ) | const |
Returns the model index of the current item.
Definition at line 1128 of file qabstractitemview.cpp.
|
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.
Reimplemented in TreeView, QtTestTableView, QTreeView, QListView, QHeaderView, QTreeWidgetDataChanged, QTableWidgetDataChanged, and QListWidgetDataChanged.
Definition at line 3387 of file qabstractitemview.cpp.
|
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.
Definition at line 3981 of file qabstractitemview.cpp.
|
protected |
Definition at line 4006 of file qabstractitemview.cpp.
|
virtualslot |
Reimplemented in QTreeView, QTableView, QListView, and QHeaderView.
Definition at line 1263 of file qabstractitemview.cpp.
|
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.
|
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.
Definition at line 1236 of file qabstractitemview.cpp.
|
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.
Reimplemented in PieView.
Definition at line 2746 of file qabstractitemview.cpp.
This function is called when the given editor has been destroyed.
Definition at line 3033 of file qabstractitemview.cpp.
QAbstractItemView::EditTriggers QAbstractItemView::editTriggers | ( | ) | const |
Definition at line 1286 of file qabstractitemview.cpp.
|
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.
|
overrideprotected |
\reimp
Definition at line 1679 of file qabstractitemview.cpp.
\reimp
Definition at line 4701 of file qabstractitemview.cpp.
|
protected |
Executes the scheduled layouts without waiting for the event processing to begin.
Definition at line 3934 of file qabstractitemview.cpp.
|
overrideprotected |
This function is called with the given event when the widget obtains the focus. By default, the event is ignored.
Definition at line 2290 of file qabstractitemview.cpp.
|
overrideprotected |
\reimp
Definition at line 1664 of file qabstractitemview.cpp.
|
overrideprotected |
This function is called with the given event when the widget loses the focus. By default, the event is ignored.
Definition at line 2325 of file qabstractitemview.cpp.
bool QAbstractItemView::hasAutoScroll | ( | ) | const |
Definition at line 1423 of file qabstractitemview.cpp.
|
protectedpure virtual |
Returns the horizontal offset of the view.
In the base class this is a pure virtual function.
Implemented in MyAbstractItemView, QTreeView, QTableView, QListView, QHeaderView, QColumnViewPreviewColumn, QColumnView, and PieView.
|
protectedvirtualslot |
Reimplemented in QTreeView, and QTableView.
Definition at line 2916 of file qabstractitemview.cpp.
|
protectedvirtualslot |
QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode | ( | ) | const |
Definition at line 1355 of file qabstractitemview.cpp.
QSize QAbstractItemView::iconSize | ( | ) | const |
Definition at line 1637 of file qabstractitemview.cpp.
|
pure virtual |
Returns the model index of the item at the viewport coordinates point.
In the base class this is a pure virtual function.
Implemented in QColumnView, PieView, QTreeView, QTableView, QListView, QHeaderView, MyAbstractItemView, and QColumnViewPreviewColumn.
QWidget * QAbstractItemView::indexWidget | ( | const QModelIndex & | index | ) | const |
Returns the widget for the item at the given index.
Definition at line 3319 of file qabstractitemview.cpp.
|
protectedvirtual |
Initialize the option structure with the view's palette, font, state, alignments etc.
Reimplemented in QComboBoxListView, QTableView, and QListView.
Definition at line 3859 of file qabstractitemview.cpp.
|
overrideprotected |
\reimp
Definition at line 2629 of file qabstractitemview.cpp.
|
overridevirtual |
\reimp
Reimplemented in QInputDialogListView.
Definition at line 887 of file qabstractitemview.cpp.
|
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 QTreeView, QTableView, QListView, QHeaderView, QColumnView, PieView, MyAbstractItemView, and QColumnViewPreviewColumn.
bool QAbstractItemView::isPersistentEditorOpen | ( | const QModelIndex & | index | ) | const |
Returns whether a persistent editor is open for the item at index index.
Definition at line 3255 of file qabstractitemview.cpp.
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.
Definition at line 879 of file qabstractitemview.cpp.
QAbstractItemDelegate * QAbstractItemView::itemDelegateForColumn | ( | int | column | ) | const |
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.
Definition at line 1026 of file qabstractitemview.cpp.
|
virtual |
Returns the item delegate used by this view and model for the given index.
Definition at line 1047 of file qabstractitemview.cpp.
QAbstractItemDelegate * QAbstractItemView::itemDelegateForRow | ( | int | row | ) | const |
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.
Definition at line 966 of file qabstractitemview.cpp.
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 QTreeView.
Definition at line 3053 of file qabstractitemview.cpp.
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.
Definition at line 2343 of file qabstractitemview.cpp.
QAbstractItemModel * QAbstractItemView::model | ( | ) | const |
Returns the model that this view is presenting.
Definition at line 758 of file qabstractitemview.cpp.
|
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 2003 of file qabstractitemview.cpp.
|
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 1875 of file qabstractitemview.cpp.
|
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 1800 of file qabstractitemview.cpp.
|
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.
|
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 PieView, MyAbstractItemView, QHeaderView, QColumnViewPreviewColumn, QTreeView, QTableView, QListView, QColumnView, and FreezeTableWidget.
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.
Definition at line 3216 of file qabstractitemview.cpp.
|
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.
|
virtualslot |
Reset the internal state of the view.
Reimplemented in QTreeView, QListView, and QHeaderView.
Definition at line 1144 of file qabstractitemview.cpp.
void QAbstractItemView::resetHorizontalScrollMode | ( | ) |
Definition at line 1361 of file qabstractitemview.cpp.
void QAbstractItemView::resetVerticalScrollMode | ( | ) |
Definition at line 1324 of file qabstractitemview.cpp.
|
overrideprotected |
This function is called with the given event when a resize event is sent to the widget.
Definition at line 2580 of file qabstractitemview.cpp.
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.
Definition at line 1192 of file qabstractitemview.cpp.
|
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.
Reimplemented in QTreeView, and QListView.
Definition at line 3458 of file qabstractitemview.cpp.
|
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.
Reimplemented in QTreeView, QListView, QHeaderView, and QColumnView.
Definition at line 3444 of file qabstractitemview.cpp.
|
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.
Definition at line 3922 of file qabstractitemview.cpp.
|
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().
Definition at line 3966 of file qabstractitemview.cpp.
|
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 QTreeView, QTableView, QListView, QColumnView, FreezeTableWidget, PieView, QHeaderView, MyAbstractItemView, and QColumnViewPreviewColumn.
|
slot |
Scrolls the view to the bottom.
Definition at line 3348 of file qabstractitemview.cpp.
|
slot |
Scrolls the view to the top.
Definition at line 3336 of file qabstractitemview.cpp.
|
virtualslot |
Selects all items in the view. This function will use the selection behavior set on the view when selecting.
Reimplemented in QTreeView, and QColumnView.
Definition at line 1204 of file qabstractitemview.cpp.
|
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.
Reimplemented in QTreeView, QTableView, and QListView.
Definition at line 2719 of file qabstractitemview.cpp.
QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior | ( | ) | const |
Definition at line 1091 of file qabstractitemview.cpp.
|
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.
Reimplemented in QTreeView, QTableView, and QListView.
Definition at line 3758 of file qabstractitemview.cpp.
|
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.
Reimplemented in QTableViewSelectCells, and DeselectTableWidget.
Definition at line 4098 of file qabstractitemview.cpp.
QAbstractItemView::SelectionMode QAbstractItemView::selectionMode | ( | ) | const |
Definition at line 1069 of file qabstractitemview.cpp.
QItemSelectionModel * QAbstractItemView::selectionModel | ( | ) | const |
Returns the current selection model.
Definition at line 824 of file qabstractitemview.cpp.
void QAbstractItemView::setAlternatingRowColors | ( | bool | enable | ) |
Definition at line 1606 of file qabstractitemview.cpp.
void QAbstractItemView::setAutoScroll | ( | bool | enable | ) |
Definition at line 1417 of file qabstractitemview.cpp.
void QAbstractItemView::setAutoScrollMargin | ( | int | margin | ) |
Definition at line 1437 of file qabstractitemview.cpp.
|
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);}
Definition at line 1111 of file qabstractitemview.cpp.
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.
Definition at line 3950 of file qabstractitemview.cpp.
void QAbstractItemView::setEditTriggers | ( | EditTriggers | triggers | ) |
void QAbstractItemView::setHorizontalScrollMode | ( | ScrollMode | mode | ) |
Definition at line 1341 of file qabstractitemview.cpp.
void QAbstractItemView::setIndexWidget | ( | const QModelIndex & | index, |
QWidget * | widget | ||
) |
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.
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.
Definition at line 3287 of file qabstractitemview.cpp.
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.
Definition at line 845 of file qabstractitemview.cpp.
void QAbstractItemView::setItemDelegateForColumn | ( | int | column, |
QAbstractItemDelegate * | delegate | ||
) |
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.
Definition at line 992 of file qabstractitemview.cpp.
void QAbstractItemView::setItemDelegateForRow | ( | int | row, |
QAbstractItemDelegate * | delegate | ||
) |
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.
Definition at line 932 of file qabstractitemview.cpp.
|
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:
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.
Reimplemented in QtTestTableView, QTreeView, QTableView, QHeaderView, and QColumnView.
Definition at line 682 of file qabstractitemview.cpp.
|
virtualslot |
Sets the root item to the item at the given index.
Reimplemented in QTreeView, QTableView, QListView, and QColumnView.
Definition at line 1174 of file qabstractitemview.cpp.
|
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.
Implemented in SetSelectionTestView, QHeaderView, QTreeView, QTableView, QListView, QColumnView, MyAbstractItemView, QColumnViewPreviewColumn, and PieView.
void QAbstractItemView::setSelectionBehavior | ( | QAbstractItemView::SelectionBehavior | behavior | ) |
void QAbstractItemView::setSelectionMode | ( | QAbstractItemView::SelectionMode | mode | ) |
|
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.
Reimplemented in QTreeWidget, QTreeView, QTableView, QListWidget, and QColumnView.
Definition at line 778 of file qabstractitemview.cpp.
Sets the item view's state to the given state.
Definition at line 3907 of file qabstractitemview.cpp.
void QAbstractItemView::setTabKeyNavigation | ( | bool | enable | ) |
Definition at line 1454 of file qabstractitemview.cpp.
void QAbstractItemView::setTextElideMode | ( | Qt::TextElideMode | mode | ) |
void QAbstractItemView::setVerticalScrollMode | ( | ScrollMode | mode | ) |
Definition at line 1302 of file qabstractitemview.cpp.
|
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.
Reimplemented in QTreeView, and QTableView.
Definition at line 3187 of file qabstractitemview.cpp.
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.
Definition at line 3129 of file qabstractitemview.cpp.
|
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.
Reimplemented in QTableView.
Definition at line 3156 of file qabstractitemview.cpp.
|
protected |
|
protected |
Returns the item view's state.
Definition at line 3896 of file qabstractitemview.cpp.
|
protected |
bool QAbstractItemView::tabKeyNavigation | ( | ) | const |
Definition at line 1460 of file qabstractitemview.cpp.
Qt::TextElideMode QAbstractItemView::textElideMode | ( | ) | const |
Definition at line 1656 of file qabstractitemview.cpp.
|
overrideprotected |
This function is called with the given event when a timer event is sent to the widget.
Definition at line 2592 of file qabstractitemview.cpp.
|
slot |
Updates the area occupied by the given index.
Definition at line 3364 of file qabstractitemview.cpp.
|
protectedvirtualslot |
Definition at line 2810 of file qabstractitemview.cpp.
|
protectedvirtualslot |
Definition at line 2820 of file qabstractitemview.cpp.
|
protectedvirtualslot |
Updates the geometry of the child widgets of the view.
Reimplemented in QTreeView, QTableView, QListView, and QHeaderView.
Definition at line 2871 of file qabstractitemview.cpp.
|
protectedpure virtual |
Returns the vertical offset of the view.
In the base class this is a pure virtual function.
Implemented in MyAbstractItemView, QTreeView, QTableView, QListView, QHeaderView, QColumnViewPreviewColumn, QColumnView, and PieView.
|
protectedvirtualslot |
Reimplemented in QTableView.
Definition at line 2908 of file qabstractitemview.cpp.
|
protectedvirtualslot |
Definition at line 2882 of file qabstractitemview.cpp.
QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode | ( | ) | const |
Definition at line 1318 of file qabstractitemview.cpp.
|
signal |
|
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 1734 of file qabstractitemview.cpp.
|
overrideprotected |
Definition at line 1470 of file qabstractitemview.cpp.
|
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.
Implemented in QTreeView, QTableView, QListView, QHeaderView, QColumnView, PieView, MyAbstractItemView, and QColumnViewPreviewColumn.
|
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.
Implemented in QTreeView, QTableView, QListView, QHeaderView, QColumnView, PieView, MyAbstractItemView, and QColumnViewPreviewColumn.
|
friend |
Definition at line 384 of file qabstractitemview.h.
|
friend |
Definition at line 382 of file qabstractitemview.h.
|
friend |
Definition at line 383 of file qabstractitemview.h.
|
friend |
Definition at line 381 of file qabstractitemview.h.
|
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 389 of file qabstractitemview.h.
|
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 389 of file qabstractitemview.h.
|
readwrite |
the size of the area when auto scrolling is triggered
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 389 of file qabstractitemview.h.
|
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 389 of file qabstractitemview.h.
|
readwrite |
how the view scrolls its contents in the horizontal direction
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 389 of file qabstractitemview.h.
|
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 389 of file qabstractitemview.h.
|
readwrite |
which selection behavior the view uses
This property holds whether selections are done in terms of single items, rows or columns.
Definition at line 389 of file qabstractitemview.h.
|
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.
Definition at line 389 of file qabstractitemview.h.
|
readwrite |
whether item navigation with tab and backtab is enabled.
Definition at line 389 of file qabstractitemview.h.
|
readwrite |
the position of the "..." in elided text.
The default value for all item views is Qt::ElideRight.
Definition at line 389 of file qabstractitemview.h.
|
readwrite |
how the view scrolls its contents in the vertical direction
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 389 of file qabstractitemview.h.