Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Protected Types | Protected Slots | Protected Functions | Properties | Friends | List of all members
QAbstractItemView Class Referenceabstract

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

#include <qabstractitemview.h>

Inheritance diagram for QAbstractItemView:
QAbstractScrollArea QFrame QWidget QObject QPaintDevice QColumnView QColumnViewPreviewColumn QHeaderView QListView QTableView QTreeView QComboBoxListView QFileDialogListView QFontListView QListWidget QSidebar QUndoView QCalendarView QTableWidget QFileDialogTreeView QTreeWidget

Public Types

enum  DragDropMode {
  NoDragDrop, DragOnly, DropOnly, DragDrop,
  InternalMove
}
 Describes the various drag and drop events the view can act upon. 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  ScrollHint { EnsureVisible, PositionAtTop, PositionAtBottom, PositionAtCenter }
 
enum  ScrollMode { ScrollPerItem, ScrollPerPixel }
 
enum  SelectionBehavior { SelectItems, SelectRows, SelectColumns }
 
enum  SelectionMode {
  NoSelection, SingleSelection, MultiSelection, ExtendedSelection,
  ContiguousSelection
}
 This enum indicates how the view responds to user selections: More...
 
- Public Types inherited from QFrame
enum  Shadow { Plain = 0x0010, Raised = 0x0020, Sunken = 0x0030 }
 This enum type defines the types of shadow that are used to give a 3D effect to frames. More...
 
enum  Shape {
  NoFrame = 0, Box = 0x0001, Panel = 0x0002, WinPanel = 0x0003,
  HLine = 0x0004, VLine = 0x0005, StyledPanel = 0x0006
}
 This enum type defines the shapes of frame available. More...
 
enum  StyleMask { Shadow_Mask = 0x00f0, Shape_Mask = 0x000f }
 This enum defines two constants that can be used to extract the two components of frameStyle(): More...
 
- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
 This enum describes how to render the widget when calling QWidget::render(). More...
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Public Slots

void clearSelection ()
 Deselects all selected items. More...
 
virtual void doItemsLayout ()
 This function is intended to lay out the items in the view. More...
 
void edit (const QModelIndex &index)
 Starts editing the item corresponding to the given index if it is editable. More...
 
virtual void reset ()
 Reset the internal state of the view. More...
 
void scrollToBottom ()
 Scrolls the view to the bottom. More...
 
void scrollToTop ()
 Scrolls the view to the top. More...
 
virtual void selectAll ()
 Selects all items in the view. More...
 
void setCurrentIndex (const QModelIndex &index)
 Sets the current item to be the item at index. More...
 
virtual void setRootIndex (const QModelIndex &index)
 Sets the root item to the item at the given index. More...
 
void update (const QModelIndex &index)
 Updates the area occupied by the given index. More...
 
- Public Slots inherited from QWidget
bool close ()
 Closes this widget. More...
 
void hide ()
 Hides the widget. More...
 
void lower ()
 Lowers the widget to the bottom of the parent widget's stack. More...
 
void raise ()
 Raises this widget to the top of the parent widget's stack. More...
 
void repaint ()
 Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More...
 
void setDisabled (bool)
 Disables widget input events if disable is true; otherwise enables input events. More...
 
void setEnabled (bool)
 
void setFocus ()
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setHidden (bool hidden)
 Convenience function, equivalent to setVisible(!hidden). More...
 
QT_MOC_COMPAT void setShown (bool shown)
 Use setVisible(shown) instead. More...
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void show ()
 Shows the widget and its child widgets. More...
 
void showFullScreen ()
 Shows the widget in full-screen mode. More...
 
void showMaximized ()
 Shows the widget maximized. More...
 
void showMinimized ()
 Shows the widget minimized, as an icon. More...
 
void showNormal ()
 Restores the widget after it has been maximized or minimized. More...
 
void update ()
 Updates the widget unless updates are disabled or the widget is hidden. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void activated (const QModelIndex &index)
 This signal is emitted when the item specified by index is activated by the user. More...
 
void clicked (const QModelIndex &index)
 This signal is emitted when a mouse button is clicked. More...
 
void doubleClicked (const QModelIndex &index)
 This signal is emitted when a mouse button is double-clicked. More...
 
void entered (const QModelIndex &index)
 This signal is emitted when the mouse cursor enters the item specified by index. More...
 
void pressed (const QModelIndex &index)
 This signal is emitted when a mouse button is pressed. More...
 
void viewportEntered ()
 This signal is emitted when the mouse cursor enters the viewport. More...
 
- Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

bool alternatingRowColors () const
 
int autoScrollMargin () const
 
void closePersistentEditor (const QModelIndex &index)
 Closes the persistent editor for the item at the given index. More...
 
QModelIndex currentIndex () const
 Returns the model index of the current item. More...
 
Qt::DropAction defaultDropAction () const
 
DragDropMode dragDropMode () const
 
bool dragDropOverwriteMode () const
 
bool dragEnabled () const
 
EditTriggers editTriggers () const
 
bool hasAutoScroll () const
 
ScrollMode horizontalScrollMode () const
 
QSize iconSize () const
 
virtual QModelIndex indexAt (const QPoint &point) const =0
 Returns the model index of the item at the viewport coordinates point. More...
 
QWidgetindexWidget (const QModelIndex &index) const
 Returns the widget for the item at the given index. More...
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 Reimplemented Function More...
 
QAbstractItemDelegateitemDelegate () const
 Returns the item delegate used by this view and model. More...
 
QAbstractItemDelegateitemDelegate (const QModelIndex &index) const
 Returns the item delegate used by this view and model for the given index. More...
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 Returns the item delegate used by this view and model for the given column. More...
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 Returns the item delegate used by this view and model for the given row, or 0 if no delegate has been assigned. More...
 
virtual void keyboardSearch (const QString &search)
 Moves to and selects the item best matching the string search. More...
 
QAbstractItemModelmodel () const
 Returns the model that this view is presenting. More...
 
void openPersistentEditor (const QModelIndex &index)
 Opens a persistent editor on the item at the given index. More...
 
 QAbstractItemView (QWidget *parent=0)
 Constructs an abstract item view with the given parent. More...
 
QModelIndex rootIndex () const
 Returns the model index of the model's root item. More...
 
virtual void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
 Scrolls the view if necessary to ensure that the item at index is visible. More...
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QAbstractItemView::SelectionMode selectionMode () const
 
QItemSelectionModelselectionModel () const
 Returns the current selection model. More...
 
void setAlternatingRowColors (bool enable)
 
void setAutoScroll (bool enable)
 
void setAutoScrollMargin (int margin)
 
void setDefaultDropAction (Qt::DropAction dropAction)
 
void setDragDropMode (DragDropMode behavior)
 
void setDragDropOverwriteMode (bool overwrite)
 
void setDragEnabled (bool enable)
 
void setDropIndicatorShown (bool enable)
 
void setEditTriggers (EditTriggers triggers)
 
void setHorizontalScrollMode (ScrollMode mode)
 
void setIconSize (const QSize &size)
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 Sets the given widget on the item at the given index, passing the ownership of the widget to the viewport. More...
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 Sets the item delegate for this view and its model to delegate. More...
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 Sets the given item delegate used by this view and model for the given column. More...
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 Sets the given item delegate used by this view and model for the given row. More...
 
virtual void setModel (QAbstractItemModel *model)
 Sets the model for the view to present. More...
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
virtual void setSelectionModel (QItemSelectionModel *selectionModel)
 Sets the current selection model to the given selectionModel. More...
 
void setTabKeyNavigation (bool enable)
 
void setTextElideMode (Qt::TextElideMode mode)
 
void setVerticalScrollMode (ScrollMode mode)
 
bool showDropIndicator () const
 
virtual int sizeHintForColumn (int column) const
 Returns the width size hint for the specified column or -1 if there is no model. More...
 
QSize sizeHintForIndex (const QModelIndex &index) const
 Returns the size hint for the item with the specified index or an invalid size for invalid indexes. More...
 
virtual int sizeHintForRow (int row) const
 Returns the height size hint for the specified row or -1 if there is no model. More...
 
bool tabKeyNavigation () const
 
Qt::TextElideMode textElideMode () const
 
ScrollMode verticalScrollMode () const
 
virtual QRect visualRect (const QModelIndex &index) const =0
 Returns the rectangle on the viewport occupied by the item at index. More...
 
 ~QAbstractItemView ()
 Destroys the view. More...
 
- Public Functions inherited from QAbstractScrollArea
void addScrollBarWidget (QWidget *widget, Qt::Alignment alignment)
 Adds widget as a scroll bar widget in the location specified by alignment. More...
 
QWidgetcornerWidget () const
 Returns the widget in the corner between the two scroll bars. More...
 
QScrollBarhorizontalScrollBar () const
 Returns the horizontal scroll bar. More...
 
Qt::ScrollBarPolicy horizontalScrollBarPolicy () const
 
QSize maximumViewportSize () const
 Returns the size of the viewport as if the scroll bars had no valid scrolling range. More...
 
QSize minimumSizeHint () const
 Reimplemented Function More...
 
 QAbstractScrollArea (QWidget *parent=0)
 Constructs a viewport. More...
 
QWidgetList scrollBarWidgets (Qt::Alignment alignment)
 Returns a list of the currently set scroll bar widgets. More...
 
void setCornerWidget (QWidget *widget)
 Sets the widget in the corner between the two scroll bars to be widget. More...
 
void setHorizontalScrollBar (QScrollBar *scrollbar)
 Replaces the existing horizontal scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. More...
 
void setHorizontalScrollBarPolicy (Qt::ScrollBarPolicy)
 
void setVerticalScrollBar (QScrollBar *scrollbar)
 Replaces the existing vertical scroll bar with scrollBar, and sets all the former scroll bar's slider properties on the new scroll bar. More...
 
void setVerticalScrollBarPolicy (Qt::ScrollBarPolicy)
 
void setViewport (QWidget *widget)
 Sets the viewport to be the given widget. More...
 
QSize sizeHint () const
 Reimplemented Function More...
 
QScrollBarverticalScrollBar () const
 Returns the vertical scroll bar. More...
 
Qt::ScrollBarPolicy verticalScrollBarPolicy () const
 
QWidgetviewport () const
 Returns the viewport widget. More...
 
 ~QAbstractScrollArea ()
 Destroys the viewport. More...
 
- Public Functions inherited from QFrame
QRect frameRect () const
 
Shadow frameShadow () const
 
Shape frameShape () const
 
int frameStyle () const
 Returns the frame style. More...
 
int frameWidth () const
 
int lineWidth () const
 
int midLineWidth () const
 
 QFrame (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a frame widget with frame style NoFrame and a 1-pixel frame width. More...
 
void setFrameRect (const QRect &)
 em>Reimplemented Function More...
 
void setFrameShadow (Shadow)
 
void setFrameShape (Shape)
 
void setFrameStyle (int)
 Sets the frame style to style. More...
 
void setLineWidth (int)
 
void setMidLineWidth (int)
 
QSize sizeHint () const
 em>Reimplemented Function More...
 
 ~QFrame ()
 Destroys the frame. More...
 
- Public Functions inherited from QWidget
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void activateWindow ()
 Sets the top-level widget containing this widget to be the active window. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to fit its contents. More...
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 Returns the background role of the widget. More...
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More...
 
QWidgetchildAt (const QPoint &p) const
 Returns the visible child widget at point p in the widget's own coordinate system. More...
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 Takes keyboard input focus from the widget. More...
 
void clearMask ()
 Removes any mask set by setMask(). More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 Returns the area inside the widget's margins. More...
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void createWinId ()
 
QCursor cursor () const
 
int devType () const
 
WId effectiveWinId () const
 Returns the effective window system identifier of the widget, i. More...
 
void ensurePolished () const
 Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More...
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 Returns the focus proxy, or 0 if there is no focus proxy. More...
 
QWidgetfocusWidget () const
 Returns the last child of this widget that setFocus had been called on. More...
 
const QFontfont () const
 
QFontInfo fontInfo () const
 Returns the font info for the widget's current font. More...
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the widget's current font. More...
 
QPalette::ColorRole foregroundRole () const
 Returns the foreground role. More...
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the widget's contents margins for left, top, right, and bottom. More...
 
HDC getDC () const
 Returns the window system handle of the widget, for low-level access. More...
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the widget to a given gesture with specific flags. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
void grabMouse (const QCursor &)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
QGraphicsEffectgraphicsEffect () const
 The graphicsEffect function returns a pointer to the widget's graphics effect. More...
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More...
 
bool hasFocus () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int) const
 Returns the preferred height for this widget, given the width w. More...
 
QInputContextinputContext ()
 This function returns the QInputContext for this widget. More...
 
Qt::InputMethodHints inputMethodHints () const
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
WId internalWinId () const
 Returns the window system identifier of the widget, or 0 if the widget is not created yet. More...
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More...
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *) const
 Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More...
 
bool isEnabledToTLW () const
 This function is deprecated. More...
 
bool isFullScreen () const
 
bool isHidden () const
 Returns true if the widget is hidden, otherwise returns false. More...
 
bool isLeftToRight () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isRightToLeft () const
 
bool isTopLevel () const
 Use isWindow() instead. More...
 
bool isVisible () const
 
bool isVisibleTo (QWidget *) const
 Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More...
 
bool isWindow () const
 Returns true if the widget is an independent window, otherwise returns false. More...
 
bool isWindowModified () const
 
QLayoutlayout () const
 Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More...
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
Qt::HANDLE macCGHandle () const
 Returns the CoreGraphics handle of the widget. More...
 
Qt::HANDLE macQDHandle () const
 Returns the QuickDraw handle of the widget. More...
 
QPoint mapFrom (QWidget *, const QPoint &) const
 Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More...
 
QPoint mapFromGlobal (const QPoint &) const
 Translates the global screen coordinate pos to widget coordinates. More...
 
QPoint mapFromParent (const QPoint &) const
 Translates the parent widget coordinate pos to widget coordinates. More...
 
QPoint mapTo (QWidget *, const QPoint &) const
 Translates the widget coordinate pos to the coordinate system of parent. More...
 
QPoint mapToGlobal (const QPoint &) const
 Translates the widget coordinate pos to global screen coordinates. More...
 
QPoint mapToParent (const QPoint &) const
 Translates the widget coordinate pos to a coordinate in the parent widget. More...
 
QRegion mask () const
 Returns the mask currently set on a widget. More...
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (int x, int y)
 This corresponds to move(QPoint(x, y)). More...
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 Returns the native parent for this widget, i. More...
 
QWidgetnextInFocusChain () const
 Returns the next widget in this widget's focus chain. More...
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags type)
 Sets the window flags for the widget to flags, without telling the window system. More...
 
void overrideWindowState (Qt::WindowStates state)
 
QPaintEnginepaintEngine () const
 Returns the widget's paint engine. More...
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 Returns the parent of this widget, or 0 if it does not have any parent widget. More...
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a widget which is a child of parent, with widget flags set to f. More...
 
QRect rect () const
 
void releaseDC (HDC) const
 Releases the HDC hdc acquired by a previous call to getDC(). More...
 
void releaseKeyboard ()
 Releases the keyboard grab. More...
 
void releaseMouse ()
 Releases the mouse grab. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More...
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the widget into the painter's QPainter::device(). More...
 
void repaint (int x, int y, int w, int h)
 This version repaints a rectangle (x, y, w, h) inside the widget. More...
 
void repaint (const QRect &)
 This version repaints a rectangle rect inside the widget. More...
 
void repaint (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void resize (int w, int h)
 This corresponds to resize(QSize(w, h)). More...
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 Restores the geometry and state top-level widgets stored in the byte array geometry. More...
 
QByteArray saveGeometry () const
 Saves the current geometry and state for top-level widgets. More...
 
void scroll (int dx, int dy)
 Scrolls the widget including its children dx pixels to the right and dy downward. More...
 
void scroll (int dx, int dy, const QRect &)
 This version only scrolls r and does not move the children of the widget. More...
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More...
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole)
 Sets the background role of the widget to role. More...
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 This corresponds to setBaseSize(QSize(basew, baseh)). More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More...
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setFixedHeight (int h)
 Sets both the minimum and maximum heights of the widget to h without changing the widths. More...
 
void setFixedSize (const QSize &)
 Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More...
 
void setFixedSize (int w, int h)
 Sets the width of the widget to w and the height to h. More...
 
void setFixedWidth (int w)
 Sets both the minimum and maximum width of the widget to w without changing the heights. More...
 
void setFocus (Qt::FocusReason reason)
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *)
 Sets the widget's focus proxy to widget w. More...
 
void setFont (const QFont &)
 Use the single-argument overload instead. More...
 
void setForegroundRole (QPalette::ColorRole)
 Sets the foreground role of the widget to role. More...
 
void setGeometry (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More...
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 The setGraphicsEffect function is for setting the widget's graphics effect. More...
 
void setInputContext (QInputContext *)
 This function sets the input context context on this widget. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *)
 Sets the layout manager for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &)
 Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More...
 
void setMask (const QRegion &)
 Causes only the parts of the widget which overlap region to be visible. More...
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 This function corresponds to setMaximumSize(QSize(maxw, maxh)). More...
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 This function corresponds to setMinimumSize(QSize(minw, minh)). More...
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 Use the single-argument overload instead. More...
 
void setParent (QWidget *parent)
 Sets the parent of the widget to parent, and resets the window flags. More...
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 This function also takes widget flags, f as an argument. More...
 
void setShortcutAutoRepeat (int id, bool enable=true)
 If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enable=true)
 If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 Sets the x (width) size increment to w and the y (height) size increment to h. More...
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More...
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *)
 Sets the widget's GUI style to style. More...
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 Sets up the user interface for the specified widget. More...
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &)
 Sets the window's role to role. More...
 
void setWindowState (Qt::WindowStates state)
 Sets the window state to windowState. More...
 
void setWindowSurface (QWindowSurface *surface)
 Sets the window surface to be the surface specified. More...
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *)
 Places the widget under w in the parent widget's stack. More...
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute) const
 Returns true if attribute attribute is set on this widget; otherwise returns false. More...
 
QString toolTip () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 Returns true if the widget is under the mouse cursor; otherwise returns false. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the widget from a given gesture type. More...
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 This version updates a rectangle (x, y, w, h) inside the widget. More...
 
void update (const QRect &)
 This version updates a rectangle rect inside the widget. More...
 
void update (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void updateGeometry ()
 Notifies the layout system that this widget has changed and may need to change geometry. More...
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 Returns the unobscured region where paint events can occur. More...
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 Returns the window for this widget, i.e. More...
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 Window flags are a combination of a type (e. More...
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 Returns the window's role, or an empty string. More...
 
Qt::WindowStates windowState () const
 Returns the current window state. More...
 
QWindowSurfacewindowSurface () const
 Returns the QWindowSurface this widget will be drawn into. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the window type of this widget. More...
 
WId winId () const
 Returns the window system identifier of the widget. More...
 
int x () const
 
const QX11Infox11Info () const
 Returns information about the configuration of the X display used to display the widget. More...
 
Qt::HANDLE x11PictureHandle () const
 Returns the X11 Picture handle of the widget for XRender support. More...
 
int y () const
 
 ~QWidget ()
 Destroys the widget. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

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  DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport }
 This enum indicates the position of the drop indicator in relation to the index at the current mouse position: More...
 
enum  State {
  NoState, DraggingState, DragSelectingState, EditingState,
  ExpandingState, CollapsingState, AnimatingState
}
 Describes the different states the view can be in. More...
 

Protected Slots

virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 Closes the given editor, and releases it. More...
 
virtual void commitData (QWidget *editor)
 Commit the data in the editor to the model. More...
 
virtual void currentChanged (const QModelIndex &current, const QModelIndex &previous)
 This slot is called when a new item becomes the current item. More...
 
virtual void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 This slot is called when items are changed in the model. More...
 
virtual void editorDestroyed (QObject *editor)
 This function is called when the given editor has been destroyed. More...
 
virtual void horizontalScrollbarAction (int action)
 
virtual void horizontalScrollbarValueChanged (int value)
 
virtual void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 This slot is called when rows are about to be removed. More...
 
virtual void rowsInserted (const QModelIndex &parent, int start, int end)
 This slot is called when rows are inserted. More...
 
virtual void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 This slot is called when the selection is changed. More...
 
virtual void updateEditorData ()
 Updates the data shown in the open editor widgets in the view. More...
 
virtual void updateEditorGeometries ()
 Updates the geometry of the open editor widgets in the view. More...
 
virtual void updateGeometries ()
 Updates the geometry of the child widgets of the view. More...
 
virtual void verticalScrollbarAction (int action)
 
virtual void verticalScrollbarValueChanged (int value)
 
- Protected Slots inherited from QAbstractScrollArea
void setupViewport (QWidget *viewport)
 This slot is called by QAbstractScrollArea after setViewport(viewport) has been called. More...
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 Updates the widget's micro focus. More...
 

Protected Functions

QPoint dirtyRegionOffset () const
 Returns the offset of the dirty regions in the view. More...
 
void doAutoScroll ()
 
void dragEnterEvent (QDragEnterEvent *event)
 This function is called with the given event when a drag and drop operation enters the widget. More...
 
void dragLeaveEvent (QDragLeaveEvent *event)
 This function is called when the item being dragged leaves the view. More...
 
void dragMoveEvent (QDragMoveEvent *event)
 This function is called continuously with the given event during a drag and drop operation over the widget. More...
 
void dropEvent (QDropEvent *event)
 This function is called with the given event when a drop event occurs over the widget. More...
 
DropIndicatorPosition dropIndicatorPosition () const
 Returns the position of the drop indicator in relation to the closest item. More...
 
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 State is now EditingState; otherwise returns false. More...
 
bool event (QEvent *event)
 Reimplemented Function More...
 
void executeDelayedItemsLayout ()
 Executes the scheduled layouts without waiting for the event processing to begin. More...
 
void focusInEvent (QFocusEvent *event)
 This function is called with the given event when the widget obtains the focus. More...
 
bool focusNextPrevChild (bool next)
 Reimplemented Function More...
 
void focusOutEvent (QFocusEvent *event)
 This function is called with the given event when the widget looses the focus. More...
 
virtual int horizontalOffset () const =0
 Returns the horizontal offset of the view. More...
 
int horizontalStepsPerItem () const
 Returns the horizontal scroll bar's steps per item. More...
 
void inputMethodEvent (QInputMethodEvent *event)
 Reimplemented Function More...
 
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. More...
 
void keyPressEvent (QKeyEvent *event)
 This function is called with the given event when a key event is sent to the widget. More...
 
void mouseDoubleClickEvent (QMouseEvent *event)
 This function is called with the given event when a mouse button is double clicked inside the widget. More...
 
void mouseMoveEvent (QMouseEvent *event)
 This function is called with the given event when a mouse move event is sent to the widget. More...
 
void mousePressEvent (QMouseEvent *event)
 This function is called with the given event when a mouse button is pressed while the cursor is inside the widget. More...
 
void mouseReleaseEvent (QMouseEvent *event)
 This function is called with the given event when a mouse button is released, after a mouse press event on the widget. More...
 
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. More...
 
 QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=0)
 
void resizeEvent (QResizeEvent *event)
 This function is called with the given event when a resize event is sent to the widget. More...
 
void scheduleDelayedItemsLayout ()
 Schedules a layout of the items in the view to be executed when the event processing starts. More...
 
void scrollDirtyRegion (int dx, int dy)
 Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite direction. More...
 
virtual QModelIndexList selectedIndexes () const
 This convenience function returns a list of all selected and non-hidden item indexes in the view. More...
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=0) const
 Returns the SelectionFlags to be used when updating a selection with to include the index specified. More...
 
void setDirtyRegion (const QRegion &region)
 Marks the given region as dirty and schedules it to be updated. More...
 
void setHorizontalStepsPerItem (int steps)
 Sets the horizontal scroll bar's steps per item to steps. More...
 
virtual void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
 Applies the selection flags to the items in or touched by the rectangle, rect. More...
 
void setState (State state)
 Sets the item view's state to the given state. More...
 
void setVerticalStepsPerItem (int steps)
 Sets the vertical scroll bar's steps per item to steps. More...
 
void startAutoScroll ()
 
virtual void startDrag (Qt::DropActions supportedActions)
 Starts a drag by calling drag->exec() using the given supportedActions. More...
 
State state () const
 Returns the item view's state. More...
 
void stopAutoScroll ()
 
void timerEvent (QTimerEvent *event)
 This function is called with the given event when a timer event is sent to the widget. More...
 
virtual int verticalOffset () const =0
 Returns the vertical offset of the view. More...
 
int verticalStepsPerItem () const
 Returns the vertical scroll bar's steps per item. More...
 
virtual QStyleOptionViewItem viewOptions () const
 Returns a QStyleOptionViewItem structure populated with the view's palette, font, state, alignments etc. More...
 
bool viewportEvent (QEvent *event)
 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. More...
 
virtual QRegion visualRegionForSelection (const QItemSelection &selection) const =0
 Returns the region from the viewport of the items in the given selection. More...
 
- Protected Functions inherited from QAbstractScrollArea
void contextMenuEvent (QContextMenuEvent *)
 This event handler can be reimplemented in a subclass to receive context menu events for the viewport() widget. More...
 
void dragEnterEvent (QDragEnterEvent *)
 This event handler can be reimplemented in a subclass to receive drag enter events (passed in event), for the viewport() widget. More...
 
void dragLeaveEvent (QDragLeaveEvent *)
 This event handler can be reimplemented in a subclass to receive drag leave events (passed in event), for the viewport() widget. More...
 
void dragMoveEvent (QDragMoveEvent *)
 This event handler can be reimplemented in a subclass to receive drag move events (passed in event), for the viewport() widget. More...
 
void dropEvent (QDropEvent *)
 This event handler can be reimplemented in a subclass to receive drop events (passed in event), for the viewport() widget. More...
 
bool event (QEvent *)
 Reimplemented Function More...
 
void keyPressEvent (QKeyEvent *)
 This function is called with key event e when key presses occur. More...
 
void mouseDoubleClickEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse double click events for the viewport() widget. More...
 
void mouseMoveEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse move events for the viewport() widget. More...
 
void mousePressEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse press events for the viewport() widget. More...
 
void mouseReleaseEvent (QMouseEvent *)
 This event handler can be reimplemented in a subclass to receive mouse release events for the viewport() widget. More...
 
void paintEvent (QPaintEvent *)
 This event handler can be reimplemented in a subclass to receive paint events (passed in event), for the viewport() widget. More...
 
 QAbstractScrollArea (QAbstractScrollAreaPrivate &dd, QWidget *parent=0)
 Creates a new QAbstractScrollAreaPrivate, dd with the given parent. More...
 
void resizeEvent (QResizeEvent *)
 This event handler can be reimplemented in a subclass to receive resize events (passed in event), for the viewport() widget. More...
 
virtual void scrollContentsBy (int dx, int dy)
 This virtual handler is called when the scroll bars are moved by dx, dy, and consequently the viewport's contents should be scrolled accordingly. More...
 
void setViewportMargins (int left, int top, int right, int bottom)
 Sets the margins around the scrolling area to left, top, right and bottom. More...
 
void setViewportMargins (const QMargins &margins)
 Sets margins around the scrolling area. More...
 
void wheelEvent (QWheelEvent *)
 This event handler can be reimplemented in a subclass to receive wheel events for the viewport() widget. More...
 
- Protected Functions inherited from QFrame
void changeEvent (QEvent *)
 This event handler can be reimplemented to handle state changes. More...
 
void drawFrame (QPainter *)
 em>Reimplemented Function More...
 
bool event (QEvent *e)
 Reimplemented Function More...
 
void paintEvent (QPaintEvent *)
 This event handler can be reimplemented in a subclass to receive paint events passed in event. More...
 
 QFrame (QFramePrivate &dd, QWidget *parent=0, Qt::WindowFlags f=0)
 
- Protected Functions inherited from QWidget
virtual void actionEvent (QActionEvent *)
 This event handler is called with the given event whenever the widget's actions are changed. More...
 
virtual void closeEvent (QCloseEvent *)
 This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system. More...
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 Creates a new widget window if window is 0, otherwise sets the widget's window to window. More...
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 Frees up window system resources. More...
 
virtual void enabledChange (bool)
 
virtual void enterEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More...
 
bool focusNextChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More...
 
bool focusPreviousChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void fontChange (const QFont &)
 
virtual void hideEvent (QHideEvent *)
 This event handler can be reimplemented in a subclass to receive widget hide events. More...
 
virtual void keyReleaseEvent (QKeyEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget. More...
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More...
 
virtual bool macEvent (EventHandlerCallRef, EventRef)
 This special event handler can be reimplemented in a subclass to receive native Macintosh events. More...
 
int metric (PaintDeviceMetric) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
virtual void moveEvent (QMoveEvent *)
 This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More...
 
virtual void paletteChange (const QPalette &)
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
virtual bool qwsEvent (QWSEvent *)
 This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More...
 
void resetInputContext ()
 This function can be called on the widget that currently has focus to reset the input method operating on it. More...
 
virtual void showEvent (QShowEvent *)
 This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter. More...
 
virtual void styleChange (QStyle &)
 
virtual void tabletEvent (QTabletEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More...
 
virtual void windowActivationChange (bool)
 
virtual bool winEvent (MSG *message, long *result)
 This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More...
 
virtual bool x11Event (XEvent *)
 This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Properties

bool alternatingRowColors
 whether to draw the background using alternating colors More...
 
bool autoScroll
 whether autoscrolling in drag move events is enabled More...
 
int autoScrollMargin
 the size of the area when auto scrolling is triggered More...
 
Qt::DropAction defaultDropAction
 the drop action that will be used by default in QAbstractItemView::drag() More...
 
DragDropMode dragDropMode
 the drag and drop event the view will act upon More...
 
bool dragDropOverwriteMode
 the view's drag and drop behavior More...
 
bool dragEnabled
 whether the view supports dragging of its own items More...
 
EditTriggers editTriggers
 which actions will initiate item editing More...
 
ScrollMode horizontalScrollMode
 how the view scrolls its contents in the horizontal direction More...
 
QSize iconSize
 the size of items' icons More...
 
SelectionBehavior selectionBehavior
 which selection behavior the view uses More...
 
SelectionMode selectionMode
 which selection mode the view operates in More...
 
bool showDropIndicator
 whether the drop indicator is shown when dragging items and dropping. More...
 
bool tabKeyNavigation
 whether item navigation with tab and backtab is enabled. 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...
 

Friends

class QAccessibleItemRow
 
class QListModeViewBase
 
class QListViewPrivate
 
class QTreeViewPrivate
 

Additional Inherited Members

- Static Public Functions inherited from QWidget
static QWidgetfind (WId)
 Returns a pointer to the widget with window identifer/handle id. More...
 
static QWidgetkeyboardGrabber ()
 Returns the widget that is currently grabbing the keyboard input. More...
 
static QWidgetmouseGrabber ()
 Returns the widget that is currently grabbing the mouse input. More...
 
static void setTabOrder (QWidget *, QWidget *)
 Puts the second widget after the first widget in the focus order. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QPaintDevice
ushort painters
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

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

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:

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

Note that the above table assumes that the 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 Model/View Classes and is part of Qt's 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 update() as all painting operations take place on the viewport.
See also
{View Classes}, {Model/View Programming}, QAbstractItemModel, {Chart Example}

Definition at line 63 of file qabstractitemview.h.

Enumerations

◆ CursorAction

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

See also
moveCursor()
  • MoveUp Move to the item above the current item.
  • MoveDown Move to the item below the current item.
  • MoveLeft Move to the item left of the current item.
  • MoveRight Move to the item right of the current item.
  • MoveHome Move to the top-left corner item.
  • MoveEnd Move to the bottom-right corner item.
  • MovePageUp Move one page up above the current item.
  • MovePageDown Move one page down below the current item.
  • MoveNext Move to the item after the current item.
  • MovePrevious Move to the item before the current item.
Enumerator
MoveUp 
MoveDown 
MoveLeft 
MoveRight 
MoveHome 
MoveEnd 
MovePageUp 
MovePageDown 
MoveNext 
MovePrevious 

Definition at line 277 of file qabstractitemview.h.

◆ DragDropMode

Describes the various drag and drop events the view can act upon.

Since
4.2

By default the view does not support dragging or dropping (NoDragDrop).

  • NoDragDrop Does not support dragging or dropping.
  • DragOnly The view supports dragging of its own items
  • DropOnly The view accepts drops
  • DragDrop The view supports both dragging and dropping
  • InternalMove The view accepts move (not copy) operations only from itself.

Note that the model used needs to provide support for drag and drop operations.

See also
setDragDropMode() {Using drag and drop with item views}
Enumerator
NoDragDrop 
DragOnly 
DropOnly 
DragDrop 
InternalMove 

Definition at line 175 of file qabstractitemview.h.

◆ DropIndicatorPosition

This enum indicates the position of the drop indicator in relation to the index at the current mouse position:

  • OnItem The item will be dropped on the index.
  • AboveItem The item will be dropped above the index.
  • BelowItem The item will be dropped below the index.
  • OnViewport The item will be dropped onto a region of the viewport with no items. The way each view handles items dropped onto the viewport depends on the behavior of the underlying model in use.
Enumerator
OnItem 
AboveItem 
BelowItem 
OnViewport 

Definition at line 348 of file qabstractitemview.h.

◆ EditTrigger

This enum describes actions which will initiate item editing.

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

Definition at line 109 of file qabstractitemview.h.

◆ ScrollHint

  • EnsureVisible Scroll to ensure that the item is visible.
  • PositionAtTop Scroll to position the item at the top of the viewport.
  • PositionAtBottom Scroll to position the item at the bottom of the viewport.
  • PositionAtCenter Scroll to position the item at the center of the viewport.
Enumerator
EnsureVisible 
PositionAtTop 
PositionAtBottom 
PositionAtCenter 

Definition at line 102 of file qabstractitemview.h.

◆ ScrollMode

Since
4.2
  • ScrollPerItem The view will scroll the contents one item at a time.
  • ScrollPerPixel The view will scroll the contents one pixel at a time.
Enumerator
ScrollPerItem 
ScrollPerPixel 

Definition at line 121 of file qabstractitemview.h.

◆ SelectionBehavior

  • SelectItems Selecting single items.
  • SelectRows Selecting only rows.
  • SelectColumns Selecting only columns.
Enumerator
SelectItems 
SelectRows 
SelectColumns 

Definition at line 96 of file qabstractitemview.h.

◆ SelectionMode

This enum indicates how the view responds to user selections:

  • SingleSelection When the user selects an item, any already-selected item becomes unselected, and the user cannot unselect the selected item by clicking on it.
  • 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.
  • 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.
  • 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.
  • NoSelection Items cannot be selected.

The most commonly used modes are SingleSelection and ExtendedSelection.

Enumerator
NoSelection 
SingleSelection 
MultiSelection 
ExtendedSelection 
ContiguousSelection 

Definition at line 88 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.

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

Definition at line 303 of file qabstractitemview.h.

Constructors and Destructors

◆ QAbstractItemView() [1/2]

QAbstractItemView::QAbstractItemView ( QWidget parent = 0)
explicit

Constructs an abstract item view with the given parent.

Definition at line 640 of file qabstractitemview.cpp.

642 {
643  d_func()->init();
644 }
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.

◆ ~QAbstractItemView()

QAbstractItemView::~QAbstractItemView ( )

Destroys the view.

Definition at line 658 of file qabstractitemview.cpp.

659 {
661  // stop these timers here before ~QObject
662  d->delayedReset.stop();
663  d->updateTimer.stop();
664  d->delayedEditing.stop();
665  d->delayedAutoScroll.stop();
666  d->autoScrollTimer.stop();
667  d->delayedLayout.stop();
668  d->fetchMoreTimer.stop();
669 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ QAbstractItemView() [2/2]

QAbstractItemView::QAbstractItemView ( QAbstractItemViewPrivate dd,
QWidget parent = 0 
)
protected
Warning
This function is not part of the public interface.

Definition at line 649 of file qabstractitemview.cpp.

650  : QAbstractScrollArea(dd, parent)
651 {
652  d_func()->init();
653 }
QAbstractScrollArea(QWidget *parent=0)
Constructs a viewport.

Functions

◆ 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 QColumnViewPrivate::createColumn(), keyPressEvent(), QTreeView::mouseDoubleClickEvent(), mouseDoubleClickEvent(), mouseReleaseEvent(), and QTreeWidget::QTreeWidget().

◆ alternatingRowColors()

bool QAbstractItemView::alternatingRowColors ( ) const

◆ autoScrollMargin()

int QAbstractItemView::autoScrollMargin ( ) const

◆ clearSelection

void QAbstractItemView::clearSelection ( )
slot

Deselects all selected items.

The current index will not be changed.

See also
setSelection(), selectAll()

Definition at line 1225 of file qabstractitemview.cpp.

1226 {
1228  if (d->selectionModel)
1229  d->selectionModel->clearSelection();
1230 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ clicked

void QAbstractItemView::clicked ( const QModelIndex index)
signal

This signal is emitted when a mouse button is 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 QColumnViewPrivate::createColumn(), mouseReleaseEvent(), and QTreeWidget::QTreeWidget().

◆ 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 2849 of file qabstractitemview.cpp.

Referenced by closePersistentEditor(), currentChanged(), setItemDelegate(), setItemDelegateForColumn(), and setItemDelegateForRow().

2850 {
2852 
2853  // Close the editor
2854  if (editor) {
2855  bool isPersistent = d->persistent.contains(editor);
2856  bool hadFocus = editor->hasFocus();
2857  QModelIndex index = d->indexForEditor(editor);
2858  if (!index.isValid())
2859  return; // the editor was not registered
2860 
2861  if (!isPersistent) {
2862  setState(NoState);
2863  QModelIndex index = d->indexForEditor(editor);
2864  editor->removeEventFilter(d->delegateForIndex(index));
2865  d->removeEditor(editor);
2866  }
2867  if (hadFocus)
2868  setFocus(); // this will send a focusLost event to the editor
2869  else
2870  d->checkPersistentEditorFocus();
2871 
2872  QPointer<QWidget> ed = editor;
2873  QApplication::sendPostedEvents(editor, 0);
2874  editor = ed;
2875 
2876  if (!isPersistent && editor)
2877  d->releaseEditor(editor);
2878  }
2879 
2880  // The EndEditHint part
2881  QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::ClearAndSelect
2882  | d->selectionBehaviorFlags();
2883  switch (hint) {
2886  if (index.isValid()) {
2887  QPersistentModelIndex persistent(index);
2888  d->selectionModel->setCurrentIndex(persistent, flags);
2889  // currentChanged signal would have already started editing
2890  if (index.flags() & Qt::ItemIsEditable
2892  edit(persistent);
2893  } break; }
2896  if (index.isValid()) {
2897  QPersistentModelIndex persistent(index);
2898  d->selectionModel->setCurrentIndex(persistent, flags);
2899  // currentChanged signal would have already started editing
2900  if (index.flags() & Qt::ItemIsEditable
2902  edit(persistent);
2903  } break; }
2905  d->model->submit();
2906  break;
2908  d->model->revert();
2909  break;
2910  default:
2911  break;
2912  }
2913 }
double d
Definition: qnumeric_p.h:62
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
bool hasFocus() const
Definition: qwidget.cpp:6583
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...
#define Q_D(Class)
Definition: qglobal.h:2482
static void sendPostedEvents()
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
Qt::ItemFlags flags() const
Returns the flags for the item referred to by the index.
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
The QAbstractItemView class provides the basic functionality for item view classes.
The QPersistentModelIndex class is used to locate data in a data model.
The QModelIndex class is used to locate data in a data model.
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
quint16 index
EditTriggers editTriggers() const
void setState(State state)
Sets the item view&#39;s state to the given state.

◆ closePersistentEditor()

void QAbstractItemView::closePersistentEditor ( const QModelIndex index)

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

See also
openPersistentEditor()

Definition at line 3205 of file qabstractitemview.cpp.

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

3206 {
3208  if (QWidget *editor = d->editorForIndex(index).widget.data()) {
3209  if (index == selectionModel()->currentIndex())
3211  d->persistent.remove(editor);
3212  d->removeEditor(editor);
3213  d->releaseEditor(editor);
3214  }
3215 }
double d
Definition: qnumeric_p.h:62
virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
Closes the given editor, and releases it.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QItemSelectionModel * selectionModel() const
Returns the current selection model.
QModelIndex currentIndex() const
Returns the model item index for the current item, or an invalid index if there is no current item...
The QAbstractItemView class provides the basic functionality for item view classes.

◆ commitData

void QAbstractItemView::commitData ( QWidget editor)
protectedvirtualslot

Commit the data in the editor to the model.

See also
closeEditor()

Definition at line 2920 of file qabstractitemview.cpp.

Referenced by currentChanged(), setItemDelegate(), setItemDelegateForColumn(), and setItemDelegateForRow().

2921 {
2923  if (!editor || !d->itemDelegate || d->currentlyCommittingEditor)
2924  return;
2925  QModelIndex index = d->indexForEditor(editor);
2926  if (!index.isValid())
2927  return;
2928  d->currentlyCommittingEditor = editor;
2929  QAbstractItemDelegate *delegate = d->delegateForIndex(index);
2930  editor->removeEventFilter(delegate);
2931  delegate->setModelData(editor, d->model, index);
2932  editor->installEventFilter(delegate);
2933  d->currentlyCommittingEditor = 0;
2934 }
double d
Definition: qnumeric_p.h:62
The QAbstractItemDelegate class is used to display and edit data items from a model.
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
Definition: qobject.cpp:2099
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Sets the data for the item at the given index in the model to the contents of the given editor...
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
Definition: qobject.cpp:2070
The QModelIndex class is used to locate data in a data model.
quint16 index

◆ 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 QTreeView, QHeaderView, QListView, QTableView, QColumnView, and QFontListView.

Definition at line 3671 of file qabstractitemview.cpp.

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

3672 {
3674  Q_ASSERT(d->model);
3675 
3676  if (previous.isValid()) {
3677  QModelIndex buddy = d->model->buddy(previous);
3678  QWidget *editor = d->editorForIndex(buddy).widget.data();
3679  if (editor && !d->persistent.contains(editor)) {
3680  commitData(editor);
3681  if (current.row() != previous.row())
3683  else
3685  }
3686  if (isVisible()) {
3687  update(previous);
3688  }
3689  }
3690 
3691  if (current.isValid() && !d->autoScrollTimer.isActive()) {
3692  if (isVisible()) {
3693  if (d->autoScroll)
3694  scrollTo(current);
3695  update(current);
3696  edit(current, CurrentChanged, 0);
3697  if (current.row() == (d->model->rowCount(d->root) - 1))
3698  d->fetchMore();
3699  } else {
3700  d->shouldScrollToCurrentOnShow = d->autoScroll;
3701  }
3702  }
3703 }
double d
Definition: qnumeric_p.h:62
virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
Closes the given editor, and releases it.
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void commitData(QWidget *editor)
Commit the data in the editor to the model.
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
int row() const
Returns the row this model index refers to.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.

◆ currentIndex()

QModelIndex QAbstractItemView::currentIndex ( ) const

Returns the model index of the current item.

See also
setCurrentIndex()

Definition at line 1112 of file qabstractitemview.cpp.

Referenced by QTableWidget::currentColumn(), QTreeWidget::currentColumn(), QFontListView::currentItem(), QListWidget::currentItem(), QTableWidget::currentItem(), QTreeWidget::currentItem(), QTableWidget::currentRow(), QFontListView::currentText(), QAccessibleItemRow::doAction(), QTreeView::drawRow(), event(), QComboBoxPrivateContainer::eventFilter(), focusInEvent(), QCalendarWidgetPrivate::getCurrentDate(), inputMethodEvent(), inputMethodQuery(), QTreeView::keyboardSearch(), keyboardSearch(), QComboBoxPrivate::keyboardSearchString(), QTreeView::keyPressEvent(), keyPressEvent(), mousePressEvent(), QColumnView::moveCursor(), QTableView::moveCursor(), QListView::moveCursor(), QTreeView::moveCursor(), QCalendarView::moveCursor(), QAccessibleItemRow::navigate(), openPersistentEditor(), QListView::paintEvent(), rowsAboutToBeRemoved(), setCurrentIndex(), QListWidget::setCurrentItem(), timerEvent(), viewportEvent(), and QCalendarView::wheelEvent().

1113 {
1114  Q_D(const QAbstractItemView);
1115  return d->selectionModel ? d->selectionModel->currentIndex() : QModelIndex();
1116 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.

◆ dataChanged

void QAbstractItemView::dataChanged ( const QModelIndex topLeft,
const QModelIndex bottomRight 
)
protectedvirtualslot

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

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

Reimplemented in QHeaderView, QListView, and QTreeView.

Definition at line 3348 of file qabstractitemview.cpp.

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

3349 {
3350  // Single item changed
3352  if (topLeft == bottomRight && topLeft.isValid()) {
3353  const QEditorInfo &editorInfo = d->editorForIndex(topLeft);
3354  //we don't update the edit data if it is static
3355  if (!editorInfo.isStatic && editorInfo.widget) {
3356  QAbstractItemDelegate *delegate = d->delegateForIndex(topLeft);
3357  if (delegate) {
3358  delegate->setEditorData(editorInfo.widget.data(), topLeft);
3359  }
3360  }
3361  if (isVisible() && !d->delayedPendingLayout) {
3362  // otherwise the items will be update later anyway
3363  update(topLeft);
3364  }
3365  return;
3366  }
3367  d->updateEditorData(topLeft, bottomRight);
3368  if (!isVisible() || d->delayedPendingLayout)
3369  return; // no need to update
3370  d->viewport->update();
3371 }
double d
Definition: qnumeric_p.h:62
The QAbstractItemDelegate class is used to display and edit data items from a model.
bool isVisible() const
Definition: qwidget.h:1005
QWeakPointer< QWidget > widget
#define Q_D(Class)
Definition: qglobal.h:2482
T * data() const
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets the contents of the given editor to the data for the item at the given index.

◆ defaultDropAction()

Qt::DropAction QAbstractItemView::defaultDropAction ( ) const

Referenced by setDefaultDropAction(), and startDrag().

◆ 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 3875 of file qabstractitemview.cpp.

3876 {
3877  Q_D(const QAbstractItemView);
3878  return d->scrollDelayOffset;
3879 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ doAutoScroll()

void QAbstractItemView::doAutoScroll ( )
protected
Warning
This function is not part of the public interface.

Definition at line 3900 of file qabstractitemview.cpp.

Referenced by timerEvent().

3901 {
3902  // find how much we should scroll with
3904  int verticalStep = verticalScrollBar()->pageStep();
3905  int horizontalStep = horizontalScrollBar()->pageStep();
3906  if (d->autoScrollCount < qMax(verticalStep, horizontalStep))
3907  ++d->autoScrollCount;
3908 
3909  int margin = d->autoScrollMargin;
3910  int verticalValue = verticalScrollBar()->value();
3911  int horizontalValue = horizontalScrollBar()->value();
3912 
3913  QPoint pos = d->viewport->mapFromGlobal(QCursor::pos());
3914  QRect area = static_cast<QAbstractItemView*>(d->viewport)->d_func()->clipRect(); // access QWidget private by bending C++ rules
3915 
3916  // do the scrolling if we are in the scroll margins
3917  if (pos.y() - area.top() < margin)
3918  verticalScrollBar()->setValue(verticalValue - d->autoScrollCount);
3919  else if (area.bottom() - pos.y() < margin)
3920  verticalScrollBar()->setValue(verticalValue + d->autoScrollCount);
3921  if (pos.x() - area.left() < margin)
3922  horizontalScrollBar()->setValue(horizontalValue - d->autoScrollCount);
3923  else if (area.right() - pos.x() < margin)
3924  horizontalScrollBar()->setValue(horizontalValue + d->autoScrollCount);
3925  // if nothing changed, stop scrolling
3926  bool verticalUnchanged = (verticalValue == verticalScrollBar()->value());
3927  bool horizontalUnchanged = (horizontalValue == horizontalScrollBar()->value());
3928  if (verticalUnchanged && horizontalUnchanged) {
3929  stopAutoScroll();
3930  } else {
3931 #ifndef QT_NO_DRAGANDDROP
3932  d->dropIndicatorRect = QRect();
3933  d->dropIndicatorPosition = QAbstractItemView::OnViewport;
3934 #endif
3935  d->viewport->update();
3936  }
3937 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QScrollBar * verticalScrollBar() const
Returns the vertical scroll bar.
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int value() const
The QAbstractItemView class provides the basic functionality for item view classes.
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QScrollBar * horizontalScrollBar() const
Returns the horizontal scroll bar.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
int pageStep() const
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
static int area(const QSize &s)
Definition: qicon.cpp:155

◆ doItemsLayout

void QAbstractItemView::doItemsLayout ( )
virtualslot

This function is intended to lay out the items in the view.

Warning
This function is not part of the public interface.

The default implementation just calls updateGeometries() and updates the viewport.

Reimplemented in QHeaderView, QTreeView, QListView, and QTableView.

Definition at line 1241 of file qabstractitemview.cpp.

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

1242 {
1244  d->interruptDelayedItemsLayout();
1245  updateGeometries();
1246  d->viewport->update();
1247 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.

◆ 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 QColumnViewPrivate::createColumn(), QTreeView::mouseDoubleClickEvent(), mouseDoubleClickEvent(), and QTreeWidget::QTreeWidget().

◆ dragDropMode()

DragDropMode QAbstractItemView::dragDropMode ( ) const

◆ dragDropOverwriteMode()

bool QAbstractItemView::dragDropOverwriteMode ( ) const

◆ dragEnabled()

bool QAbstractItemView::dragEnabled ( ) const

Referenced by setDragDropMode(), and setDragEnabled().

◆ dragEnterEvent()

void QAbstractItemView::dragEnterEvent ( QDragEnterEvent event)
protectedvirtual

This function is called with the given event when a drag and drop operation enters the widget.

If the drag is over a valid dropping place (e.g. over an item that accepts drops), the event is accepted; otherwise it is ignored.

See also
dropEvent() startDrag()

Reimplemented from QWidget.

Definition at line 1987 of file qabstractitemview.cpp.

Referenced by QSidebar::dragEnterEvent().

1988 {
1989  if (dragDropMode() == InternalMove
1990  && (event->source() != this|| !(event->possibleActions() & Qt::MoveAction)))
1991  return;
1992 
1993  if (d_func()->canDecode(event)) {
1994  event->accept();
1996  } else {
1997  event->ignore();
1998  }
1999 }
DragDropMode dragDropMode() const
QWidget * source() const
If the source of the drag operation is a widget in this application, this function returns that sourc...
Definition: qevent.cpp:2739
void setState(State state)
Sets the item view&#39;s state to the given state.

◆ dragLeaveEvent()

void QAbstractItemView::dragLeaveEvent ( QDragLeaveEvent event)
protectedvirtual

This function is called when the item being dragged leaves the view.

The event describes the state of the drag and drop operation.

Reimplemented from QWidget.

Reimplemented in QListView.

Definition at line 2107 of file qabstractitemview.cpp.

Referenced by QListView::dragLeaveEvent().

2108 {
2110  stopAutoScroll();
2111  setState(NoState);
2112  d->hover = QModelIndex();
2113  d->viewport->update();
2114 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
void setState(State state)
Sets the item view&#39;s state to the given state.

◆ dragMoveEvent()

void QAbstractItemView::dragMoveEvent ( QDragMoveEvent event)
protectedvirtual

This function is called continuously with the given event during a drag and drop operation over the widget.

It can cause the view to scroll if, for example, the user drags a selection to view's right or bottom edge. In this case, the event will be accepted; otherwise it will be ignored.

See also
dropEvent() startDrag()

Reimplemented from QWidget.

Reimplemented in QTreeView, and QListView.

Definition at line 2009 of file qabstractitemview.cpp.

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

2010 {
2012  if (dragDropMode() == InternalMove
2013  && (event->source() != this || !(event->possibleActions() & Qt::MoveAction)))
2014  return;
2015 
2016  // ignore by default
2017  event->ignore();
2018 
2019  QModelIndex index = indexAt(event->pos());
2020  d->hover = index;
2021  if (!d->droppingOnItself(event, index)
2022  && d->canDecode(event)) {
2023 
2024  if (index.isValid() && d->showDropIndicator) {
2025  QRect rect = visualRect(index);
2026  d->dropIndicatorPosition = d->position(event->pos(), rect, index);
2027  switch (d->dropIndicatorPosition) {
2028  case AboveItem:
2029  if (d->isIndexDropEnabled(index.parent())) {
2030  d->dropIndicatorRect = QRect(rect.left(), rect.top(), rect.width(), 0);
2031  event->accept();
2032  } else {
2033  d->dropIndicatorRect = QRect();
2034  }
2035  break;
2036  case BelowItem:
2037  if (d->isIndexDropEnabled(index.parent())) {
2038  d->dropIndicatorRect = QRect(rect.left(), rect.bottom(), rect.width(), 0);
2039  event->accept();
2040  } else {
2041  d->dropIndicatorRect = QRect();
2042  }
2043  break;
2044  case OnItem:
2045  if (d->isIndexDropEnabled(index)) {
2046  d->dropIndicatorRect = rect;
2047  event->accept();
2048  } else {
2049  d->dropIndicatorRect = QRect();
2050  }
2051  break;
2052  case OnViewport:
2053  d->dropIndicatorRect = QRect();
2054  if (d->isIndexDropEnabled(rootIndex())) {
2055  event->accept(); // allow dropping in empty areas
2056  }
2057  break;
2058  }
2059  } else {
2060  d->dropIndicatorRect = QRect();
2061  d->dropIndicatorPosition = OnViewport;
2062  if (d->isIndexDropEnabled(rootIndex())) {
2063  event->accept(); // allow dropping in empty areas
2064  }
2065  }
2066  d->viewport->update();
2067  } // can decode
2068 
2069  if (d->shouldAutoScroll(event->pos()))
2070  startAutoScroll();
2071 }
double d
Definition: qnumeric_p.h:62
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
DragDropMode dragDropMode() const
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_D(Class)
Definition: qglobal.h:2482
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QRect rect() const
The QAbstractItemView class provides the basic functionality for item view classes.
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QWidget * source() const
If the source of the drag operation is a widget in this application, this function returns that sourc...
Definition: qevent.cpp:2739
The QModelIndex class is used to locate data in a data model.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
QModelIndex rootIndex() const
Returns the model index of the model&#39;s root item.
const QPoint & pos() const
Returns the position where the drop was made.
Definition: qevent.h:486
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.

◆ dropEvent()

void QAbstractItemView::dropEvent ( QDropEvent event)
protectedvirtual

This function is called with the given event when a drop event occurs over the widget.

If the model accepts the even position the drop event is accepted; otherwise it is ignored.

See also
startDrag()

Reimplemented from QWidget.

Reimplemented in QTreeWidget, QTableWidget, QListWidget, and QListView.

Definition at line 2123 of file qabstractitemview.cpp.

Referenced by QListView::dropEvent(), QTableWidget::dropEvent(), and QTreeWidget::dropEvent().

2124 {
2126  if (dragDropMode() == InternalMove) {
2127  if (event->source() != this || !(event->possibleActions() & Qt::MoveAction))
2128  return;
2129  }
2130 
2132  int col = -1;
2133  int row = -1;
2134  if (d->dropOn(event, &row, &col, &index)) {
2135  if (d->model->dropMimeData(event->mimeData(),
2136  dragDropMode() == InternalMove ? Qt::MoveAction : event->dropAction(), row, col, index)) {
2137  if (dragDropMode() == InternalMove)
2138  event->setDropAction(Qt::MoveAction);
2139  event->accept();
2140  }
2141  }
2142  stopAutoScroll();
2143  setState(NoState);
2144  d->viewport->update();
2145 }
double d
Definition: qnumeric_p.h:62
void setDropAction(Qt::DropAction action)
Sets the action to be performed on the data by the target.
Definition: qevent.cpp:2746
DragDropMode dragDropMode() const
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
QWidget * source() const
If the source of the drag operation is a widget in this application, this function returns that sourc...
Definition: qevent.cpp:2739
The QModelIndex class is used to locate data in a data model.
quint16 index
const QMimeData * mimeData() const
Returns the data that was dropped on the widget and its associated MIME type information.
Definition: qevent.h:498
void setState(State state)
Sets the item view&#39;s state to the given state.

◆ dropIndicatorPosition()

QAbstractItemView::DropIndicatorPosition QAbstractItemView::dropIndicatorPosition ( ) const
protected

Returns the position of the drop indicator in relation to the closest item.

Since
4.1

Definition at line 2631 of file qabstractitemview.cpp.

Referenced by QListWidget::dropMimeData(), QTableWidget::dropMimeData(), and QAbstractItemViewPrivate::dropOn().

2632 {
2633  Q_D(const QAbstractItemView);
2634  return d->dropIndicatorPosition;
2635 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ 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 1211 of file qabstractitemview.cpp.

Referenced by QFileDialogPrivate::_q_createDirectory(), closeEditor(), currentChanged(), QListWidget::editItem(), QTableWidget::editItem(), QTreeWidget::editItem(), inputMethodEvent(), keyPressEvent(), QTreeView::mouseDoubleClickEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), and timerEvent().

1212 {
1214  if (!d->isIndexValid(index))
1215  qWarning("edit: index was invalid");
1216  if (!edit(index, AllEditTriggers, 0))
1217  qWarning("edit: editing failed");
1218 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
The QAbstractItemView class provides the basic functionality for item view classes.
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.

◆ 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 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 2674 of file qabstractitemview.cpp.

2675 {
2677 
2678  if (!d->isIndexValid(index))
2679  return false;
2680 
2681  if (QWidget *w = (d->persistent.isEmpty() ? static_cast<QWidget*>(0) : d->editorForIndex(index).widget.data())) {
2682  if (w->focusPolicy() == Qt::NoFocus)
2683  return false;
2684  w->setFocus();
2685  return true;
2686  }
2687 
2688  if (trigger == DoubleClicked) {
2689  d->delayedEditing.stop();
2690  d->delayedAutoScroll.stop();
2691  } else if (trigger == CurrentChanged) {
2692  d->delayedEditing.stop();
2693  }
2694 
2695  if (d->sendDelegateEvent(index, event)) {
2696  update(index);
2697  return true;
2698  }
2699 
2700  // save the previous trigger before updating
2701  EditTriggers lastTrigger = d->lastTrigger;
2702  d->lastTrigger = trigger;
2703 
2704  if (!d->shouldEdit(trigger, d->model->buddy(index)))
2705  return false;
2706 
2707  if (d->delayedEditing.isActive())
2708  return false;
2709 
2710  // we will receive a mouseButtonReleaseEvent after a
2711  // mouseDoubleClickEvent, so we need to check the previous trigger
2712  if (lastTrigger == DoubleClicked && trigger == SelectedClicked)
2713  return false;
2714 
2715  // we may get a double click event later
2716  if (trigger == SelectedClicked)
2717  d->delayedEditing.start(QApplication::doubleClickInterval(), this);
2718  else
2719  d->openEditor(index, d->shouldForwardEvent(trigger, event) ? event : 0);
2720 
2721  return true;
2722 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
The QAbstractItemView class provides the basic functionality for item view classes.
bool event(QEvent *event)
Reimplemented Function
static int doubleClickInterval()

◆ editorDestroyed

void QAbstractItemView::editorDestroyed ( QObject editor)
protectedvirtualslot

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

See also
closeEditor()

Definition at line 2941 of file qabstractitemview.cpp.

Referenced by QAbstractItemViewPrivate::editor().

2942 {
2944  QWidget *w = qobject_cast<QWidget*>(editor);
2945  d->removeEditor(w);
2946  d->persistent.remove(w);
2947  if (state() == EditingState)
2948  setState(NoState);
2949 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
State state() const
Returns the item view&#39;s state.
void setState(State state)
Sets the item view&#39;s state to the given state.

◆ editTriggers()

EditTriggers QAbstractItemView::editTriggers ( ) const

◆ 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 QColumnViewPrivate::createColumn(), and QTreeWidget::QTreeWidget().

◆ event()

bool QAbstractItemView::event ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Reimplemented in QCalendarView, QTreeWidget, QTableWidget, QListWidget, QHeaderView, and QListView.

Definition at line 1664 of file qabstractitemview.cpp.

Referenced by edit(), QListView::event(), QHeaderView::event(), QTableWidget::event(), QTreeWidget::event(), QCalendarView::event(), QAbstractItemViewPrivate::extendedSelectionCommand(), focusNextPrevChild(), QAbstractItemViewPrivate::multiSelectionCommand(), QAbstractItemViewPrivate::openEditor(), QTreeView::viewportEvent(), and viewportEvent().

1665 {
1667  switch (event->type()) {
1668  case QEvent::Paint:
1669  //we call this here because the scrollbars' visibility might be altered
1670  //so this can't be done in the paintEvent method
1671  d->executePostedLayout(); //make sure we set the layout properly
1672  break;
1673  case QEvent::Show:
1674  d->executePostedLayout(); //make sure we set the layout properly
1675  if (d->shouldScrollToCurrentOnShow) {
1676  d->shouldScrollToCurrentOnShow = false;
1677  const QModelIndex current = currentIndex();
1678  if (current.isValid() && (d->state == QAbstractItemView::EditingState || d->autoScroll))
1679  scrollTo(current);
1680  }
1681  break;
1682  case QEvent::LocaleChange:
1683  viewport()->update();
1684  break;
1687  updateGeometries();
1688  break;
1689  case QEvent::StyleChange:
1690  doItemsLayout();
1691  break;
1692  case QEvent::FocusOut:
1693  d->checkPersistentEditorFocus();
1694  break;
1695  case QEvent::FontChange:
1696  d->doDelayedItemsLayout(); // the size of the items will change
1697  break;
1698 #ifdef QT_SOFTKEYS_ENABLED
1701  break;
1702 #endif
1703  default:
1704  break;
1705  }
1706  return QAbstractScrollArea::event(event);
1707 }
double d
Definition: qnumeric_p.h:62
static QString standardSoftKeyText(StandardSoftKey standardKey)
virtual void doItemsLayout()
This function is intended to lay out the items in the view.
#define Q_D(Class)
Definition: qglobal.h:2482
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QWidget * viewport() const
Returns the viewport widget.
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
QModelIndex currentIndex() const
Returns the model index of the current item.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.
bool event(QEvent *)
Reimplemented Function
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ executeDelayedItemsLayout()

void QAbstractItemView::executeDelayedItemsLayout ( )
protected

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

See also
scheduleDelayedItemsLayout()

Definition at line 3825 of file qabstractitemview.cpp.

3826 {
3828  d->executePostedLayout();
3829 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ focusInEvent()

void QAbstractItemView::focusInEvent ( QFocusEvent event)
protectedvirtual

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

By default, the event is ignored.

See also
setFocus(), focusOutEvent()

Reimplemented from QWidget.

Definition at line 2240 of file qabstractitemview.cpp.

2241 {
2244 
2246  const bool currentIndexValid = currentIndex().isValid();
2247 
2248  if (model
2249  && !d->currentIndexSet
2250  && !currentIndexValid) {
2251  bool autoScroll = d->autoScroll;
2252  d->autoScroll = false;
2253  QModelIndex index = moveCursor(MoveNext, Qt::NoModifier); // first visible index
2254  if (index.isValid() && d->isIndexEnabled(index) && event->reason() != Qt::MouseFocusReason)
2256  d->autoScroll = autoScroll;
2257  }
2258 
2259  if (model && currentIndexValid) {
2260  if (currentIndex().flags() != Qt::ItemIsEditable)
2262  else
2264  }
2265 
2266  if (!currentIndexValid)
2268 
2269  d->viewport->update();
2270 }
double d
Definition: qnumeric_p.h:62
The QItemSelectionModel class keeps track of a view&#39;s selected items.
bool autoScroll
whether autoscrolling in drag move events is enabled
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...
#define Q_D(Class)
Definition: qglobal.h:2482
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
QItemSelectionModel * selectionModel() const
Returns the current selection model.
QModelIndex currentIndex() const
Returns the model index of the current item.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
quint16 index
QAbstractItemModel * model() const
Returns the model that this view is presenting.
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition: qwidget.cpp:9431

◆ focusNextPrevChild()

bool QAbstractItemView::focusNextPrevChild ( bool  next)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1649 of file qabstractitemview.cpp.

1650 {
1652  if (d->tabKeyNavigation && isEnabled() && d->viewport->isEnabled()) {
1654  keyPressEvent(&event);
1655  if (event.isAccepted())
1656  return true;
1657  }
1659 }
double d
Definition: qnumeric_p.h:62
The QKeyEvent class describes a key event.
Definition: qevent.h:224
#define Q_D(Class)
Definition: qglobal.h:2482
void keyPressEvent(QKeyEvent *event)
This function is called with the given event when a key event is sent to the widget.
bool isEnabled() const
Definition: qwidget.h:948
The QAbstractItemView class provides the basic functionality for item view classes.
virtual bool focusNextPrevChild(bool next)
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can&#39;t.
Definition: qwidget.cpp:6836
bool event(QEvent *event)
Reimplemented Function

◆ focusOutEvent()

void QAbstractItemView::focusOutEvent ( QFocusEvent event)
protectedvirtual

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

By default, the event is ignored.

See also
clearFocus(), focusInEvent()

Reimplemented from QWidget.

Definition at line 2278 of file qabstractitemview.cpp.

2279 {
2282  d->viewport->update();
2283 
2284 #ifdef QT_SOFTKEYS_ENABLED
2285  if(!hasEditFocus())
2286  removeAction(d->doneSoftKey);
2287 #endif
2288 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void focusOutEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
Definition: qwidget.cpp:9457
The QAbstractItemView class provides the basic functionality for item view classes.
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386

◆ hasAutoScroll()

bool QAbstractItemView::hasAutoScroll ( ) const

Definition at line 1388 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

1389 {
1390  Q_D(const QAbstractItemView);
1391  return d->autoScroll;
1392 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ 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 QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

Referenced by startDrag().

◆ horizontalScrollbarAction

void QAbstractItemView::horizontalScrollbarAction ( int  action)
protectedvirtualslot
Warning
This function is not part of the public interface.

Reimplemented in QTreeView, and QTableView.

Definition at line 2835 of file qabstractitemview.cpp.

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

2836 {
2837  //do nothing
2838 }

◆ horizontalScrollbarValueChanged

void QAbstractItemView::horizontalScrollbarValueChanged ( int  value)
protectedvirtualslot
Warning
This function is not part of the public interface.

Definition at line 2814 of file qabstractitemview.cpp.

2815 {
2817  if (horizontalScrollBar()->maximum() == value && d->model->canFetchMore(d->root))
2818  d->model->fetchMore(d->root);
2819  QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos());
2820  if (viewport()->rect().contains(posInVp))
2821  d->checkMouseMove(posInVp);
2822 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * viewport() const
Returns the viewport widget.
QRect rect() const
The QAbstractItemView class provides the basic functionality for item view classes.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QScrollBar * horizontalScrollBar() const
Returns the horizontal scroll bar.
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310

◆ horizontalScrollMode()

ScrollMode QAbstractItemView::horizontalScrollMode ( ) const

◆ horizontalStepsPerItem()

int QAbstractItemView::horizontalStepsPerItem ( ) const
protected

Returns the horizontal scroll bar's steps per item.

See also
setHorizontalStepsPerItem() verticalStepsPerItem()

Definition at line 2981 of file qabstractitemview.cpp.

2982 {
2983  return 1;
2984 }

◆ iconSize()

QSize QAbstractItemView::iconSize ( ) const

◆ indexAt()

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

◆ indexWidget()

QWidget * QAbstractItemView::indexWidget ( const QModelIndex index) const

Returns the widget for the item at the given index.

Since
4.1

Definition at line 3275 of file qabstractitemview.cpp.

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

3276 {
3277  Q_D(const QAbstractItemView);
3278  if (d->isIndexValid(index))
3279  if (QWidget *editor = d->editorForIndex(index).widget.data())
3280  return editor;
3281 
3282  return 0;
3283 }
double d
Definition: qnumeric_p.h:62
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ inputMethodEvent()

void QAbstractItemView::inputMethodEvent ( QInputMethodEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 2588 of file qabstractitemview.cpp.

2589 {
2590  if (event->commitString().isEmpty() && event->preeditString().isEmpty()) {
2591  event->ignore();
2592  return;
2593  }
2594  if (!edit(currentIndex(), AnyKeyPressed, event)) {
2595  if (!event->commitString().isEmpty())
2596  keyboardSearch(event->commitString());
2597  event->ignore();
2598  }
2599 }
const QString & commitString() const
Returns the text that should get added to (or replace parts of) the text of the editor widget...
Definition: qevent.h:457
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QModelIndex currentIndex() const
Returns the model index of the current item.
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
virtual void keyboardSearch(const QString &search)
Moves to and selects the item best matching the string search.

◆ inputMethodQuery()

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

Reimplemented Function

Reimplemented from QWidget.

Definition at line 886 of file qabstractitemview.cpp.

887 {
888  const QModelIndex current = currentIndex();
889  if (!current.isValid() || query != Qt::ImMicroFocus)
891  return visualRect(current);
892 }
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
QModelIndex currentIndex() const
Returns the model index of the current item.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QModelIndex class is used to locate data in a data model.

◆ 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 QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

Referenced by QAccessibleItemRow::children(), rowsAboutToBeRemoved(), selectedIndexes(), and QAccessibleItemRow::text().

◆ itemDelegate() [1/2]

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()

Definition at line 878 of file qabstractitemview.cpp.

Referenced by QColumnViewPrivate::initialize(), QColumnView::initializeColumn(), QComboBox::itemDelegate(), QTreeViewPrivate::paintAlternatingRowColors(), QComboBox::setItemDelegate(), QFontComboBox::setWritingSystem(), QTableView::sizeHintForColumn(), and QTableView::sizeHintForRow().

879 {
880  return d_func()->itemDelegate;
881 }

◆ itemDelegate() [2/2]

QAbstractItemDelegate * QAbstractItemView::itemDelegate ( const QModelIndex index) const

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

Definition at line 1025 of file qabstractitemview.cpp.

1026 {
1027  Q_D(const QAbstractItemView);
1028  return d->delegateForIndex(index);
1029 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ itemDelegateForColumn()

QAbstractItemDelegate * QAbstractItemView::itemDelegateForColumn ( int  column) const

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

Since
4.2

You can call itemDelegate() to get a pointer to the current delegate for a given index.

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

Definition at line 1015 of file qabstractitemview.cpp.

1016 {
1017  Q_D(const QAbstractItemView);
1018  return d->columnDelegates.value(column, 0);
1019 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ itemDelegateForRow()

QAbstractItemDelegate * QAbstractItemView::itemDelegateForRow ( int  row) const

Returns the item delegate used by this view and model for the given row, or 0 if no delegate has been assigned.

Since
4.2

You can call itemDelegate() to get a pointer to the current delegate for a given index.

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

Definition at line 952 of file qabstractitemview.cpp.

953 {
954  Q_D(const QAbstractItemView);
955  return d->rowDelegates.value(row, 0);
956 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ 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 QCalendarView, and QTreeView.

Definition at line 3029 of file qabstractitemview.cpp.

Referenced by inputMethodEvent(), QComboBoxPrivate::keyboardSearchString(), and keyPressEvent().

3030 {
3032  if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root))
3033  return;
3034 
3036  : d->model->index(0, 0, d->root);
3037  bool skipRow = false;
3038  bool keyboardTimeWasValid = d->keyboardInputTime.isValid();
3039  qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart();
3040  if (search.isEmpty() || !keyboardTimeWasValid
3041  || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) {
3042  d->keyboardInput = search;
3043  skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
3044  } else {
3045  d->keyboardInput += search;
3046  }
3047 
3048  // special case for searches with same key like 'aaaaa'
3049  bool sameKey = false;
3050  if (d->keyboardInput.length() > 1) {
3051  int c = d->keyboardInput.count(d->keyboardInput.at(d->keyboardInput.length() - 1));
3052  sameKey = (c == d->keyboardInput.length());
3053  if (sameKey)
3054  skipRow = true;
3055  }
3056 
3057  // skip if we are searching for the same key or a new search started
3058  if (skipRow) {
3059  QModelIndex parent = start.parent();
3060  int newRow = (start.row() < d->model->rowCount(parent) - 1) ? start.row() + 1 : 0;
3061  start = d->model->index(newRow, start.column(), parent);
3062  }
3063 
3064  // search from start with wraparound
3065  const QString searchString = sameKey ? QString(d->keyboardInput.at(0)) : d->keyboardInput;
3066  QModelIndex current = start;
3068  QModelIndex firstMatch;
3069  QModelIndex startMatch;
3070  QModelIndexList previous;
3071  do {
3072  match = d->model->match(current, Qt::DisplayRole, searchString);
3073  if (match == previous)
3074  break;
3075  firstMatch = match.value(0);
3076  previous = match;
3077  if (firstMatch.isValid()) {
3078  if (d->isIndexEnabled(firstMatch)) {
3079  setCurrentIndex(firstMatch);
3080  break;
3081  }
3082  int row = firstMatch.row() + 1;
3083  if (row >= d->model->rowCount(firstMatch.parent()))
3084  row = 0;
3085  current = firstMatch.sibling(row, firstMatch.column());
3086 
3087  //avoid infinite loop if all the matching items are disabled.
3088  if (!startMatch.isValid())
3089  startMatch = firstMatch;
3090  else if (startMatch == firstMatch)
3091  break;
3092  }
3093  } while (current != start && firstMatch.isValid());
3094 }
static int keyboardInputInterval()
double d
Definition: qnumeric_p.h:62
unsigned char c[8]
Definition: qnumeric_p.h:62
static bool match(const uchar *found, const char *target, uint len)
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
int row() const
Returns the row this model index refers to.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
QModelIndex currentIndex() const
Returns the model index of the current item.
__int64 qint64
Definition: qglobal.h:942
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QModelIndex class is used to locate data in a data model.
quint16 index
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Appends a new row to the current test data.
Definition: qtestcase.cpp:2183
QAbstractItemModel * model() const
Returns the model that this view is presenting.
int column() const
Returns the column this model index refers to.

◆ keyPressEvent()

void QAbstractItemView::keyPressEvent ( QKeyEvent event)
protectedvirtual

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

Reimplemented from QWidget.

Reimplemented in QCalendarView, and QTreeView.

Definition at line 2301 of file qabstractitemview.cpp.

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

2302 {
2304  d->delayedAutoScroll.stop(); //any interaction with the view cancel the auto scrolling
2305 
2306 #ifdef QT_KEYPAD_NAVIGATION
2307  switch (event->key()) {
2308  case Qt::Key_Select:
2309  if (QApplication::keypadNavigationEnabled()) {
2310  if (!hasEditFocus()) {
2311  setEditFocus(true);
2312 #ifdef QT_SOFTKEYS_ENABLED
2313  // If we can't keypad navigate to any direction, there is no sense to add
2314  // "Done" softkey, since it basically does nothing when there is
2315  // only one widget in screen
2316  if(QWidgetPrivate::canKeypadNavigate(Qt::Horizontal)
2317  || QWidgetPrivate::canKeypadNavigate(Qt::Vertical))
2318  addAction(d->doneSoftKey);
2319 #endif
2320  return;
2321  }
2322  }
2323  break;
2324  case Qt::Key_Back:
2325  if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {
2326 #ifdef QT_SOFTKEYS_ENABLED
2327  removeAction(d->doneSoftKey);
2328 #endif
2329  setEditFocus(false);
2330  } else {
2331  event->ignore();
2332  }
2333  return;
2334  case Qt::Key_Down:
2335  case Qt::Key_Up:
2336  // Let's ignore vertical navigation events, only if there is no other widget
2337  // what can take the focus in vertical direction. This means widget can handle navigation events
2338  // even the widget don't have edit focus, and there is no other widget in requested direction.
2339  if(QApplication::keypadNavigationEnabled() && !hasEditFocus()
2340  && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {
2341  event->ignore();
2342  return;
2343  }
2344  break;
2345  case Qt::Key_Left:
2346  case Qt::Key_Right:
2347  // Similar logic as in up and down events
2348  if(QApplication::keypadNavigationEnabled() && !hasEditFocus()
2349  && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this))) {
2350  event->ignore();
2351  return;
2352  }
2353  break;
2354  default:
2355  if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) {
2356  event->ignore();
2357  return;
2358  }
2359  }
2360 #endif
2361 
2362 #if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
2363  if (event == QKeySequence::Copy) {
2364  QVariant variant;
2365  if (d->model)
2366  variant = d->model->data(currentIndex(), Qt::DisplayRole);
2367  if (variant.type() == QVariant::String)
2369  event->accept();
2370  }
2371 #endif
2372 
2373  QPersistentModelIndex newCurrent;
2374  d->moveCursorUpdatedView = false;
2375  switch (event->key()) {
2376  case Qt::Key_Down:
2377  newCurrent = moveCursor(MoveDown, event->modifiers());
2378  break;
2379  case Qt::Key_Up:
2380  newCurrent = moveCursor(MoveUp, event->modifiers());
2381  break;
2382  case Qt::Key_Left:
2383  newCurrent = moveCursor(MoveLeft, event->modifiers());
2384  break;
2385  case Qt::Key_Right:
2386  newCurrent = moveCursor(MoveRight, event->modifiers());
2387  break;
2388  case Qt::Key_Home:
2389  newCurrent = moveCursor(MoveHome, event->modifiers());
2390  break;
2391  case Qt::Key_End:
2392  newCurrent = moveCursor(MoveEnd, event->modifiers());
2393  break;
2394  case Qt::Key_PageUp:
2395  newCurrent = moveCursor(MovePageUp, event->modifiers());
2396  break;
2397  case Qt::Key_PageDown:
2398  newCurrent = moveCursor(MovePageDown, event->modifiers());
2399  break;
2400  case Qt::Key_Tab:
2401  if (d->tabKeyNavigation)
2402  newCurrent = moveCursor(MoveNext, event->modifiers());
2403  break;
2404  case Qt::Key_Backtab:
2405  if (d->tabKeyNavigation)
2406  newCurrent = moveCursor(MovePrevious, event->modifiers());
2407  break;
2408  }
2409 
2410  QPersistentModelIndex oldCurrent = currentIndex();
2411  if (newCurrent != oldCurrent && newCurrent.isValid() && d->isIndexEnabled(newCurrent)) {
2412  if (!hasFocus() && QApplication::focusWidget() == indexWidget(oldCurrent))
2413  setFocus();
2414  QItemSelectionModel::SelectionFlags command = selectionCommand(newCurrent, event);
2415  if (command != QItemSelectionModel::NoUpdate
2417  // note that we don't check if the new current index is enabled because moveCursor() makes sure it is
2418  if (command & QItemSelectionModel::Current) {
2419  d->selectionModel->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate);
2420  if (!indexAt(d->pressedPosition - d->offset()).isValid())
2421  d->pressedPosition = visualRect(oldCurrent).center() + d->offset();
2422  QRect rect(d->pressedPosition - d->offset(), visualRect(newCurrent).center());
2423  setSelection(rect, command);
2424  } else {
2425  d->selectionModel->setCurrentIndex(newCurrent, command);
2426  d->pressedPosition = visualRect(newCurrent).center() + d->offset();
2427  if (newCurrent.isValid()) {
2428  // We copy the same behaviour as for mousePressEvent().
2429  QRect rect(d->pressedPosition - d->offset(), QSize(1, 1));
2430  setSelection(rect, command);
2431  }
2432  }
2433  event->accept();
2434  return;
2435  }
2436  }
2437 
2438  switch (event->key()) {
2439  // ignored keys
2440  case Qt::Key_Down:
2441  case Qt::Key_Up:
2442 #ifdef QT_KEYPAD_NAVIGATION
2443  if (QApplication::keypadNavigationEnabled() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) {
2444  event->accept(); // don't change focus
2445  break;
2446  }
2447 #endif
2448  case Qt::Key_Left:
2449  case Qt::Key_Right:
2450 #ifdef QT_KEYPAD_NAVIGATION
2451  if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
2452  && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal)
2453  || (QWidgetPrivate::inTabWidget(this) && d->model->columnCount(d->root) > 1))) {
2454  event->accept(); // don't change focus
2455  break;
2456  }
2457 #endif // QT_KEYPAD_NAVIGATION
2458  case Qt::Key_Home:
2459  case Qt::Key_End:
2460  case Qt::Key_PageUp:
2461  case Qt::Key_PageDown:
2462  case Qt::Key_Escape:
2463  case Qt::Key_Shift:
2464  case Qt::Key_Control:
2465  case Qt::Key_Delete:
2466  case Qt::Key_Backspace:
2467  event->ignore();
2468  break;
2469  case Qt::Key_Space:
2470  case Qt::Key_Select:
2471  if (!edit(currentIndex(), AnyKeyPressed, event) && d->selectionModel)
2472  d->selectionModel->select(currentIndex(), selectionCommand(currentIndex(), event));
2473 #ifdef QT_KEYPAD_NAVIGATION
2474  if ( event->key()==Qt::Key_Select ) {
2475  // Also do Key_Enter action.
2476  if (currentIndex().isValid()) {
2477  if (state() != EditingState)
2479  } else {
2480  event->ignore();
2481  }
2482  }
2483 #endif
2484  break;
2485 #ifdef Q_WS_MAC
2486  case Qt::Key_Enter:
2487  case Qt::Key_Return:
2488  // Propagate the enter if you couldn't edit the item and there are no
2489  // current editors (if there are editors, the event was most likely propagated from it).
2490  if (!edit(currentIndex(), EditKeyPressed, event) && d->editorIndexHash.isEmpty())
2491  event->ignore();
2492  break;
2493 #else
2494  case Qt::Key_F2:
2495  if (!edit(currentIndex(), EditKeyPressed, event))
2496  event->ignore();
2497  break;
2498  case Qt::Key_Enter:
2499  case Qt::Key_Return:
2500  // ### we can't open the editor on enter, becuse
2501  // some widgets will forward the enter event back
2502  // to the viewport, starting an endless loop
2503  if (state() != EditingState || hasFocus()) {
2504  if (currentIndex().isValid())
2506  event->ignore();
2507  }
2508  break;
2509 #endif
2510  case Qt::Key_A:
2511  if (event->modifiers() & Qt::ControlModifier) {
2512  selectAll();
2513  break;
2514  }
2515  default: {
2516 #ifdef Q_WS_MAC
2517  if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) {
2519  break;
2520  }
2521 #endif
2522  bool modified = (event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier));
2523  if (!event->text().isEmpty() && !modified && !edit(currentIndex(), AnyKeyPressed, event)) {
2524  keyboardSearch(event->text());
2525  event->accept();
2526  } else {
2527  event->ignore();
2528  }
2529  break; }
2530  }
2531  if (d->moveCursorUpdatedView)
2532  event->accept();
2533 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
bool hasFocus() const
Definition: qwidget.cpp:6583
void setText(const QString &, Mode mode=Clipboard)
Copies text into the clipboard as plain text.
Definition: qclipboard.cpp:375
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...
#define Q_D(Class)
Definition: qglobal.h:2482
void addAction(QAction *action)
Appends the action action to this widget&#39;s list of actions.
Definition: qwidget.cpp:3317
QWidget * indexWidget(const QModelIndex &index) const
Returns the widget for the item at the given index.
QStyle * style() const
Definition: qwidget.cpp:2742
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event=0) const
Returns the SelectionFlags to be used when updating a selection with to include the index specified...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
virtual void selectAll()
Selects all items in the view.
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
const char * styleHint(const QFontDef &request)
QModelIndex currentIndex() const
Returns the model index of the current item.
void activated(const QModelIndex &index)
This signal is emitted when the item specified by index is activated by the user. ...
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QRect rect() const
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
The QAbstractItemView class provides the basic functionality for item view classes.
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
Applies the selection flags to the items in or touched by the rectangle, rect.
The QPersistentModelIndex class is used to locate data in a data model.
QString text() const
Returns the Unicode text that this key generated.
Definition: qevent.h:236
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
State state() const
Returns the item view&#39;s state.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
const char * variant
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or 0 if no widget in this applicati...
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.
virtual void keyboardSearch(const QString &search)
Moves to and selects the item best matching the string search.

◆ model()

QAbstractItemModel * QAbstractItemView::model ( ) const

Returns the model that this view is presenting.

Definition at line 768 of file qabstractitemview.cpp.

Referenced by QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(), QHeaderViewPrivate::_q_layoutAboutToBeChanged(), QAbstractItemViewPrivate::_q_modelDestroyed(), QTreeViewPrivate::_q_sortIndicatorChanged(), QAccessibleTable2::cellAt(), QTableWidget::cellWidget(), QAccessibleTree::childAt(), QAccessibleTable2::childCount(), QAccessibleTree::childCount(), QAccessibleItemView::childCount(), QAccessibleTable2::childFromLogical(), QAccessibleItemView::childIndex(), QAbstractItemViewPrivate::clearOrRemove(), QSidebar::clicked(), QColumnViewPrivate::closeColumns(), QAccessibleTable2::columnCount(), QAccessibleItemView::columnCount(), QAccessibleTable2::columnDescription(), QAccessibleItemView::columnDescription(), QAccessibleItemView::columnIndex(), QColumnView::createColumn(), QColumnViewPrivate::createColumn(), QColumnView::currentChanged(), QListWidget::dropEvent(), QTreeWidget::dropEvent(), QListWidget::dropMimeData(), QTableWidget::dropMimeData(), QTreeWidget::dropMimeData(), QAbstractItemViewPrivate::dropOn(), QCalendarView::event(), QTreeWidgetItem::executePendingSort(), QTreeViewPrivate::expand(), QAbstractItemViewPrivate::fetchMore(), QListWidget::findItems(), QTableWidget::findItems(), QTreeWidget::findItems(), QHeaderViewPrivate::flipSortIndicator(), focusInEvent(), QCalendarView::handleMouseEvent(), QTreeViewPrivate::hasVisibleChildren(), QListModel::index(), QAccessibleItemView::index(), QAccessibleTree::indexFromLogical(), QAccessibleTable2::indexOfChild(), QAccessibleTree::indexOfChild(), QSidebar::init(), QColumnView::initializeColumn(), QTreeWidgetItem::insertChild(), QTreeWidgetItem::insertChildren(), QAccessibleTable2Cell::isExpandable(), QAccessibleTable2Cell::isValid(), QAccessibleTable2HeaderCell::isValid(), QTreeWidgetItem::itemChanged(), QCalendarView::keyPressEvent(), QTreeViewPrivate::layout(), QTreeWidget::mimeTypes(), QFontListView::model(), ModelIndexIterator::ModelIndexIterator(), QCalendarView::mouseDoubleClickEvent(), QCalendarView::mouseMoveEvent(), QCalendarView::mousePressEvent(), QCalendarView::mouseReleaseEvent(), QColumnView::moveCursor(), QTableView::moveCursor(), QTreeView::moveCursor(), QCalendarView::moveCursor(), QAccessibleTree::navigate(), QAbstractItemViewPrivate::openEditor(), QAbstractItemViewPrivate::position(), QListWidgetItem::QListWidgetItem(), QTreeWidget::QTreeWidget(), QTreeWidgetItem::QTreeWidgetItem(), QTreeWidgetItemIterator::QTreeWidgetItemIterator(), QSidebar::removeEntry(), QAccessibleTable2::rowCount(), QAccessibleItemView::rowCount(), QAccessibleTable2::rowDescription(), QAccessibleItemView::rowDescription(), QAccessibleItemView::rowIndex(), QTreeViewPrivate::select(), QColumnView::selectAll(), QAbstractItemViewPrivate::selectAll(), QListViewPrivate::selectAll(), QAccessibleTable2::selectColumn(), QTableViewPrivate::selectColumn(), QAccessibleTable2::selectRow(), QTableViewPrivate::selectRow(), QSidebar::selectUrl(), QAbstractItemViewPrivate::sendDelegateEvent(), QTableWidget::setCellWidget(), QTableWidget::setCurrentCell(), QListWidgetItem::setData(), QTableWidgetItem::setData(), QTreeWidgetItem::setData(), QListWidgetItem::setFlags(), QTableWidget::setHorizontalHeaderLabels(), QHeaderView::setModel(), setModel(), QCompleter::setPopup(), QTableWidget::setRangeSelected(), QColumnView::setRootIndex(), QAccessibleItemRow::setText(), QAccessibleTable2Cell::setText(), QTableWidget::setVerticalHeaderLabels(), QComboBox::setView(), QAbstractItemViewPrivate::shouldEdit(), QCompleterPrivate::showPopup(), QSidebar::sizeHint(), QTableView::sizeHintForColumn(), QTableView::sizeHintForRow(), QTreeWidgetItem::sortChildren(), QTreeWidget::supportedDropActions(), QTreeWidgetItem::takeChild(), QTreeWidgetItem::takeChildren(), QAccessibleHeader::text(), QAccessibleItemRow::text(), QAccessibleTable2Cell::text(), QAccessibleTable2HeaderCell::text(), QAccessibleItemRow::text_helper(), QAccessibleTable2::unselectColumn(), QAccessibleTable2::unselectRow(), QColumnView::visualRegionForSelection(), QCalendarView::wheelEvent(), QListWidgetItem::~QListWidgetItem(), QTableWidgetItem::~QTableWidgetItem(), and QTreeWidgetItem::~QTreeWidgetItem().

769 {
770  Q_D(const QAbstractItemView);
771  return (d->model == QAbstractItemModelPrivate::staticEmptyModel() ? 0 : d->model);
772 }
double d
Definition: qnumeric_p.h:62
static QAbstractItemModel * staticEmptyModel()
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ mouseDoubleClickEvent()

void QAbstractItemView::mouseDoubleClickEvent ( QMouseEvent event)
protectedvirtual

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.

Reimplemented from QWidget.

Reimplemented in QCalendarView, QHeaderView, and QTreeView.

Definition at line 1956 of file qabstractitemview.cpp.

Referenced by QCalendarView::mouseDoubleClickEvent().

1957 {
1959 
1960  QModelIndex index = indexAt(event->pos());
1961  if (!index.isValid()
1962  || !d->isIndexEnabled(index)
1963  || (d->pressedIndex != index)) {
1965  event->pos(), event->button(),
1966  event->buttons(), event->modifiers());
1967  mousePressEvent(&me);
1968  return;
1969  }
1970  // signal handlers may change the model
1971  QPersistentModelIndex persistent = index;
1972  emit doubleClicked(persistent);
1973  if ((event->button() & Qt::LeftButton) && !edit(persistent, DoubleClicked, event)
1975  emit activated(persistent);
1976 }
double d
Definition: qnumeric_p.h:62
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
#define Q_D(Class)
Definition: qglobal.h:2482
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
QStyle * style() const
Definition: qwidget.cpp:2742
#define emit
Definition: qobjectdefs.h:76
void activated(const QModelIndex &index)
This signal is emitted when the item specified by index is activated by the user. ...
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
The QAbstractItemView class provides the basic functionality for item view classes.
The QPersistentModelIndex class is used to locate data in a data model.
The QModelIndex class is used to locate data in a data model.
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
quint16 index
void doubleClicked(const QModelIndex &index)
This signal is emitted when a mouse button is double-clicked.
void mousePressEvent(QMouseEvent *event)
This function is called with the given event when a mouse button is pressed while the cursor is insid...
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.

◆ mouseMoveEvent()

void QAbstractItemView::mouseMoveEvent ( QMouseEvent event)
protectedvirtual

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.

Reimplemented from QWidget.

Reimplemented in QCalendarView, QHeaderView, QTreeView, and QListView.

Definition at line 1837 of file qabstractitemview.cpp.

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

1838 {
1840  QPoint topLeft;
1841  QPoint bottomRight = event->pos();
1842 
1843  if (state() == ExpandingState || state() == CollapsingState)
1844  return;
1845 
1846 #ifndef QT_NO_DRAGANDDROP
1847  if (state() == DraggingState) {
1848  topLeft = d->pressedPosition - d->offset();
1849  if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) {
1850  d->pressedIndex = QModelIndex();
1851  startDrag(d->model->supportedDragActions());
1852  setState(NoState); // the startDrag will return when the dnd operation is done
1853  stopAutoScroll();
1854  }
1855  return;
1856  }
1857 #endif // QT_NO_DRAGANDDROP
1858 
1859  QPersistentModelIndex index = indexAt(bottomRight);
1860  QModelIndex buddy = d->model->buddy(d->pressedIndex);
1861  if ((state() == EditingState && d->hasEditor(buddy))
1862  || edit(index, NoEditTriggers, event))
1863  return;
1864 
1865  if (d->selectionMode != SingleSelection)
1866  topLeft = d->pressedPosition - d->offset();
1867  else
1868  topLeft = bottomRight;
1869 
1870  d->checkMouseMove(index);
1871 
1872 #ifndef QT_NO_DRAGANDDROP
1873  if (d->pressedIndex.isValid()
1874  && d->dragEnabled
1875  && (state() != DragSelectingState)
1876  && (event->buttons() != Qt::NoButton)
1877  && !d->selectedDraggableIndexes().isEmpty()) {
1879  return;
1880  }
1881 #endif
1882 
1883  if ((event->buttons() & Qt::LeftButton) && d->selectionAllowed(index) && d->selectionModel) {
1885  QItemSelectionModel::SelectionFlags command = selectionCommand(index, event);
1886  if (d->ctrlDragSelectionFlag != QItemSelectionModel::NoUpdate && command.testFlag(QItemSelectionModel::Toggle)) {
1887  command &= ~QItemSelectionModel::Toggle;
1888  command |= d->ctrlDragSelectionFlag;
1889  }
1890 
1891  // Do the normalize ourselves, since QRect::normalized() is flawed
1892  QRect selectionRect = QRect(topLeft, bottomRight);
1893  setSelection(selectionRect, command);
1894 
1895  // set at the end because it might scroll the view
1896  if (index.isValid()
1897  && (index != d->selectionModel->currentIndex())
1898  && d->isIndexEnabled(index))
1899  d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
1900  }
1901 }
double d
Definition: qnumeric_p.h:62
The QItemSelectionModel class keeps track of a view&#39;s selected items.
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event=0) const
Returns the SelectionFlags to be used when updating a selection with to include the index specified...
static int startDragDistance()
The QAbstractItemView class provides the basic functionality for item view classes.
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
Applies the selection flags to the items in or touched by the rectangle, rect.
The QPersistentModelIndex class is used to locate data in a data model.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QModelIndex class is used to locate data in a data model.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
State state() const
Returns the item view&#39;s state.
quint16 index
void setState(State state)
Sets the item view&#39;s state to the given state.
virtual void startDrag(Qt::DropActions supportedActions)
Starts a drag by calling drag->exec() using the given supportedActions.
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.

◆ mousePressEvent()

void QAbstractItemView::mousePressEvent ( QMouseEvent event)
protectedvirtual

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.

Reimplemented from QWidget.

Reimplemented in QCalendarView, QHeaderView, and QTreeView.

Definition at line 1778 of file qabstractitemview.cpp.

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

1779 {
1781  d->delayedAutoScroll.stop(); //any interaction with the view cancel the auto scrolling
1782  QPoint pos = event->pos();
1784 
1785  if (!d->selectionModel
1786  || (d->state == EditingState && d->hasEditor(index)))
1787  return;
1788 
1789  d->pressedAlreadySelected = d->selectionModel->isSelected(index);
1790  d->pressedIndex = index;
1791  d->pressedModifiers = event->modifiers();
1792  QItemSelectionModel::SelectionFlags command = selectionCommand(index, event);
1793  d->noSelectionOnMousePress = command == QItemSelectionModel::NoUpdate || !index.isValid();
1794  QPoint offset = d->offset();
1795  if ((command & QItemSelectionModel::Current) == 0)
1796  d->pressedPosition = pos + offset;
1797  else if (!indexAt(d->pressedPosition - offset).isValid())
1798  d->pressedPosition = visualRect(currentIndex()).center() + offset;
1799 
1800  if (edit(index, NoEditTriggers, event))
1801  return;
1802 
1803  if (index.isValid() && d->isIndexEnabled(index)) {
1804  // we disable scrollTo for mouse press so the item doesn't change position
1805  // when the user is interacting with it (ie. clicking on it)
1806  bool autoScroll = d->autoScroll;
1807  d->autoScroll = false;
1808  d->selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
1809  d->autoScroll = autoScroll;
1810  QRect rect(d->pressedPosition - offset, pos);
1811  if (command.testFlag(QItemSelectionModel::Toggle)) {
1812  command &= ~QItemSelectionModel::Toggle;
1813  d->ctrlDragSelectionFlag = d->selectionModel->isSelected(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
1814  command |= d->ctrlDragSelectionFlag;
1815  }
1816  setSelection(rect, command);
1817 
1818  // signal handlers may change the model
1819  emit pressed(index);
1820  if (d->autoScroll) {
1821  //we delay the autoscrolling to filter out double click event
1822  //100 is to be sure that there won't be a double-click misinterpreted as a 2 single clicks
1823  d->delayedAutoScroll.start(QApplication::doubleClickInterval()+100, this);
1824  }
1825 
1826  } else {
1827  // Forces a finalize() even if mouse is pressed, but not on a item
1828  d->selectionModel->select(QModelIndex(), QItemSelectionModel::Select);
1829  }
1830 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
The QItemSelectionModel class keeps track of a view&#39;s selected items.
bool autoScroll
whether autoscrolling in drag move events is enabled
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event=0) const
Returns the SelectionFlags to be used when updating a selection with to include the index specified...
#define emit
Definition: qobjectdefs.h:76
QModelIndex currentIndex() const
Returns the model index of the current item.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QRect rect() const
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
The QAbstractItemView class provides the basic functionality for item view classes.
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
Applies the selection flags to the items in or touched by the rectangle, rect.
void pressed(const QModelIndex &index)
This signal is emitted when a mouse button is pressed.
The QPersistentModelIndex class is used to locate data in a data model.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QModelIndex class is used to locate data in a data model.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
quint16 index
static int doubleClickInterval()
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.

◆ mouseReleaseEvent()

void QAbstractItemView::mouseReleaseEvent ( QMouseEvent event)
protectedvirtual

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.

Reimplemented from QWidget.

Reimplemented in QCalendarView, QHeaderView, QTreeView, and QListView.

Definition at line 1910 of file qabstractitemview.cpp.

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

1911 {
1913 
1914  QPoint pos = event->pos();
1916 
1917  if (state() == EditingState) {
1918  if (d->isIndexValid(index)
1919  && d->isIndexEnabled(index)
1920  && d->sendDelegateEvent(index, event))
1921  update(index);
1922  return;
1923  }
1924 
1925  bool click = (index == d->pressedIndex && index.isValid());
1926  bool selectedClicked = click && (event->button() & Qt::LeftButton) && d->pressedAlreadySelected;
1927  EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers);
1928  bool edited = edit(index, trigger, event);
1929 
1930  d->ctrlDragSelectionFlag = QItemSelectionModel::NoUpdate;
1931 
1932  if (d->selectionModel && d->noSelectionOnMousePress) {
1933  d->noSelectionOnMousePress = false;
1934  d->selectionModel->select(index, selectionCommand(index, event));
1935  }
1936 
1937  setState(NoState);
1938 
1939  if (click) {
1940  emit clicked(index);
1941  if (edited)
1942  return;
1943  QStyleOptionViewItemV4 option = d->viewOptionsV4();
1944  if (d->pressedAlreadySelected)
1945  option.state |= QStyle::State_Selected;
1947  emit activated(index);
1948  }
1949 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
void clicked(const QModelIndex &index)
This signal is emitted when a mouse button is clicked.
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event=0) const
Returns the SelectionFlags to be used when updating a selection with to include the index specified...
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
#define emit
Definition: qobjectdefs.h:76
const char * styleHint(const QFontDef &request)
void activated(const QModelIndex &index)
This signal is emitted when the item specified by index is activated by the user. ...
The QAbstractItemView class provides the basic functionality for item view classes.
The QPersistentModelIndex class is used to locate data in a data model.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.
State state() const
Returns the item view&#39;s state.
quint16 index
EditTrigger
This enum describes actions which will initiate item editing.
void setState(State state)
Sets the item view&#39;s state to the given state.
bool isValid() const
Returns true if this persistent model index is valid; otherwise returns false.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.

◆ 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 QCalendarView, QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

Referenced by closeEditor(), focusInEvent(), keyPressEvent(), and QAccessibleItemRow::navigate().

◆ 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()

Definition at line 3186 of file qabstractitemview.cpp.

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

3187 {
3189  QStyleOptionViewItemV4 options = d->viewOptionsV4();
3190  options.rect = visualRect(index);
3191  options.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
3192 
3193  QWidget *editor = d->editor(index, options);
3194  if (editor) {
3195  editor->show();
3196  d->persistent.insert(editor);
3197  }
3198 }
double d
Definition: qnumeric_p.h:62
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
#define Q_D(Class)
Definition: qglobal.h:2482
QModelIndex currentIndex() const
Returns the model index of the current item.
void show()
Shows the widget and its child widgets.
The QAbstractItemView class provides the basic functionality for item view classes.
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ 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 QApplication::mouseButtons() function to get the state of the mouse buttons.

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

Referenced by QColumnViewPrivate::createColumn(), mousePressEvent(), and QTreeWidget::QTreeWidget().

◆ 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, QTreeView, and QListView.

Definition at line 1128 of file qabstractitemview.cpp.

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

1129 {
1131  d->delayedReset.stop(); //make sure we stop the timer
1132  foreach (const QEditorInfo &info, d->indexEditorHash) {
1133  if (info.widget)
1134  d->releaseEditor(info.widget.data());
1135  }
1136  d->editorIndexHash.clear();
1137  d->indexEditorHash.clear();
1138  d->persistent.clear();
1139  d->currentIndexSet = false;
1140  setState(NoState);
1142  if (d->selectionModel)
1143  d->selectionModel->reset();
1144 #ifndef QT_NO_ACCESSIBILITY
1145 #ifdef Q_WS_X11
1146  if (QAccessible::isActive()) {
1149  }
1150 #endif
1151 #endif
1152 }
double d
Definition: qnumeric_p.h:62
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
static mach_timebase_info_data_t info
QWeakPointer< QWidget > widget
virtual void setRootIndex(const QModelIndex &index)
Sets the root item to the item at the given index.
#define Q_D(Class)
Definition: qglobal.h:2482
T * data() const
static bool isActive()
Returns true if an accessibility implementation has been requested during the runtime of the applicat...
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
virtual void modelReset()=0
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
QAccessibleTable2Interface * table2Interface()
Definition: qaccessible.h:432
void setState(State state)
Sets the item view&#39;s state to the given state.

◆ resizeEvent()

void QAbstractItemView::resizeEvent ( QResizeEvent event)
protectedvirtual

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

See also
QWidget::resizeEvent()

Reimplemented from QWidget.

Reimplemented in QListView, QColumnView, QComboBoxListView, and QColumnViewPreviewColumn.

Definition at line 2541 of file qabstractitemview.cpp.

Referenced by QColumnView::resizeEvent(), and QListView::resizeEvent().

2542 {
2544  updateGeometries();
2545 }
void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive resize events (passed in event)...
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.

◆ 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 1176 of file qabstractitemview.cpp.

Referenced by QColumnViewPrivate::checkColumnCreation(), dragMoveEvent(), ModelIndexIterator::ModelIndexIterator(), QColumnView::moveCursor(), QTreeView::moveCursor(), QColumnView::selectAll(), QTableWidget::setRangeSelected(), and QColumnView::visualRegionForSelection().

1177 {
1178  return QModelIndex(d_func()->root);
1179 }
The QModelIndex class is used to locate data in a data model.

◆ 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 QTreeView, and QListView.

Definition at line 3395 of file qabstractitemview.cpp.

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

3396 {
3398 
3400 
3401  // Ensure one selected item in single selection mode.
3402  QModelIndex current = currentIndex();
3403  if (d->selectionMode == SingleSelection
3404  && current.isValid()
3405  && current.row() >= start
3406  && current.row() <= end
3407  && current.parent() == parent) {
3408  int totalToRemove = end - start + 1;
3409  if (d->model->rowCount(parent) <= totalToRemove) { // no more children
3411  while (index != d->root && !d->isIndexEnabled(index))
3412  index = index.parent();
3413  if (index != d->root)
3414  setCurrentIndex(index);
3415  } else {
3416  int row = end + 1;
3417  QModelIndex next;
3418  do { // find the next visible and enabled item
3419  next = d->model->index(row++, current.column(), current.parent());
3420  } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next)));
3421  if (row > d->model->rowCount(parent)) {
3422  row = start - 1;
3423  do { // find the previous visible and enabled item
3424  next = d->model->index(row--, current.column(), current.parent());
3425  } while (next.isValid() && (isIndexHidden(next) || !d->isIndexEnabled(next)));
3426  }
3427  setCurrentIndex(next);
3428  }
3429  }
3430 
3431  // Remove all affected editors; this is more efficient than waiting for updateGeometries() to clean out editors for invalid indexes
3432  QEditorIndexHash::iterator i = d->editorIndexHash.begin();
3433  while (i != d->editorIndexHash.end()) {
3434  const QModelIndex index = i.value();
3435  if (index.row() >= start && index.row() <= end && d->model->parent(index) == parent) {
3436  QWidget *editor = i.key();
3437  QEditorInfo info = d->indexEditorHash.take(index);
3438  i = d->editorIndexHash.erase(i);
3439  if (info.widget)
3440  d->releaseEditor(editor);
3441  } else {
3442  ++i;
3443  }
3444  }
3445 }
double d
Definition: qnumeric_p.h:62
static mach_timebase_info_data_t info
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 fals...
QWeakPointer< QWidget > widget
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
int row() const
Returns the row this model index refers to.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
QModelIndex currentIndex() const
Returns the model index of the current item.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
The QModelIndex class is used to locate data in a data model.
quint16 index
static const KeyPair *const end
void setState(State state)
Sets the item view&#39;s state to the given state.
int column() const
Returns the column this model index refers to.

◆ 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 QHeaderView, QTreeView, QListView, and QColumnView.

Definition at line 3381 of file qabstractitemview.cpp.

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

3382 {
3383  if (!isVisible())
3384  d_func()->fetchMoreTimer.start(0, this); //fetch more later
3385  else
3387 }
bool isVisible() const
Definition: qwidget.h:1005
virtual void updateEditorGeometries()
Updates the geometry of the open editor widgets in the view.

◆ 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 3813 of file qabstractitemview.cpp.

Referenced by QTreeWidgetItem::setChildIndicatorPolicy().

3814 {
3816  d->doDelayedItemsLayout();
3817 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ 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 3860 of file qabstractitemview.cpp.

3861 {
3863  d->scrollDirtyRegion(dx, dy);
3864 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ 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 QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

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

◆ scrollToBottom

void QAbstractItemView::scrollToBottom ( )
slot

Scrolls the view to the bottom.

Since
4.1
See also
scrollTo(), scrollToTop()

Definition at line 3310 of file qabstractitemview.cpp.

3311 {
3313  if (d->delayedPendingLayout) {
3314  d->executePostedLayout();
3315  updateGeometries();
3316  }
3317  verticalScrollBar()->setValue(verticalScrollBar()->maximum());
3318 }
double d
Definition: qnumeric_p.h:62
QScrollBar * verticalScrollBar() const
Returns the vertical scroll bar.
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.

◆ scrollToTop

void QAbstractItemView::scrollToTop ( )
slot

Scrolls the view to the top.

Since
4.1
See also
scrollTo(), scrollToBottom()

Definition at line 3295 of file qabstractitemview.cpp.

Referenced by QCompleterPrivate::setCurrentIndex().

3296 {
3297  verticalScrollBar()->setValue(verticalScrollBar()->minimum());
3298 }
QScrollBar * verticalScrollBar() const
Returns the vertical scroll bar.

◆ 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 QTreeView, and QColumnView.

Definition at line 1188 of file qabstractitemview.cpp.

Referenced by keyPressEvent().

1189 {
1191  SelectionMode mode = d->selectionMode;
1192  if (mode == MultiSelection || mode == ExtendedSelection)
1194  |d->selectionBehaviorFlags());
1195  else if (mode != SingleSelection)
1196  d->selectAll(selectionCommand(d->model->index(0, 0, d->root)));
1197 }
SelectionMode
This enum indicates how the view responds to user selections:
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event=0) const
Returns the SelectionFlags to be used when updating a selection with to include the index specified...
The QAbstractItemView class provides the basic functionality for item view classes.

◆ 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 QTreeView, QListView, and QTableView.

Definition at line 2645 of file qabstractitemview.cpp.

Referenced by QAbstractItemViewPrivate::droppingOnItself().

2646 {
2647  Q_D(const QAbstractItemView);
2648  QModelIndexList indexes;
2649  if (d->selectionModel) {
2650  indexes = d->selectionModel->selectedIndexes();
2652  while (it != indexes.end())
2653  if (isIndexHidden(*it))
2654  it = indexes.erase(it);
2655  else
2656  ++it;
2657  }
2658  return indexes;
2659 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
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 fals...
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
#define Q_D(Class)
Definition: qglobal.h:2482
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
The QAbstractItemView class provides the basic functionality for item view classes.
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464

◆ selectionBehavior()

QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior ( ) const

◆ 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 QTreeView, QListView, and QTableView.

Definition at line 3654 of file qabstractitemview.cpp.

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

3656 {
3658  if (isVisible() && updatesEnabled()) {
3659  d->viewport->update(visualRegionForSelection(deselected) | visualRegionForSelection(selected));
3660  }
3661 }
double d
Definition: qnumeric_p.h:62
bool isVisible() const
Definition: qwidget.h:1005
bool updatesEnabled() const
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const =0
Returns the region from the viewport of the items in the given selection.

◆ selectionCommand()

QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand ( const QModelIndex index,
const QEvent event = 0 
) const
protectedvirtual

Returns the SelectionFlags to be used when updating a selection with to include the index specified.

The event is a user input event, such as a mouse or keyboard event.

Reimplement this function to define your own selection behavior.

See also
setSelection()

Definition at line 3948 of file qabstractitemview.cpp.

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

3950 {
3951  Q_D(const QAbstractItemView);
3952  switch (d->selectionMode) {
3953  case NoSelection: // Never update selection model
3955  case SingleSelection: // ClearAndSelect on valid index otherwise NoUpdate
3956  if (event && event->type() == QEvent::MouseButtonRelease)
3958  return QItemSelectionModel::ClearAndSelect|d->selectionBehaviorFlags();
3959  case MultiSelection:
3960  return d->multiSelectionCommand(index, event);
3961  case ExtendedSelection:
3962  return d->extendedSelectionCommand(index, event);
3963  case ContiguousSelection:
3964  return d->contiguousSelectionCommand(index, event);
3965  }
3967 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ selectionMode()

QAbstractItemView::SelectionMode QAbstractItemView::selectionMode ( ) const

◆ selectionModel()

QItemSelectionModel * QAbstractItemView::selectionModel ( ) const

Returns the current selection model.

See also
setSelectionModel(), selectedIndexes()

Definition at line 823 of file qabstractitemview.cpp.

Referenced by QColumnViewPrivate::_q_clicked(), QAbstractItemViewPrivate::checkPersistentEditorFocus(), QListWidget::clear(), QTableWidget::clear(), QTreeWidget::clear(), QTableWidget::clearContents(), QAbstractItemViewPrivate::clearOrRemove(), closePersistentEditor(), QAccessibleItemRow::doAction(), QInputDialogPrivate::ensureListView(), QAbstractItemViewPrivate::extendedSelectionCommand(), focusInEvent(), QComboBox::hidePopup(), QSidebar::init(), QAccessibleTable2::isColumnSelected(), QAccessibleItemView::isColumnSelected(), QListWidget::isItemSelected(), QTableWidget::isItemSelected(), QAccessibleTable2::isRowSelected(), QAccessibleTree::isRowSelected(), QAccessibleItemView::isRowSelected(), QAccessibleItemView::isSelected(), QAccessibleTable2Cell::isSelected(), QTreeView::keyboardSearch(), QInputDialogPrivate::listViewText(), QCalendarView::mouseMoveEvent(), QCalendarView::mousePressEvent(), QAccessibleItemRow::navigate(), QTreeWidget::QTreeWidget(), QSidebar::removeEntry(), QColumnView::selectAll(), QTreeView::selectAll(), QAbstractItemViewPrivate::selectAll(), QListViewPrivate::selectAll(), QAccessibleTable2::selectColumn(), QAccessibleItemView::selectColumn(), QTableViewPrivate::selectColumn(), QAccessibleTable2::selectedCellCount(), QAccessibleTable2::selectedColumnCount(), QAccessibleItemView::selectedColumnCount(), QAccessibleItemView::selectedColumns(), QTreeView::selectedIndexes(), QListWidget::selectedItems(), QTableWidget::selectedItems(), QTreeWidget::selectedItems(), QTableWidget::selectedRanges(), QAccessibleTable2::selectedRowCount(), QAccessibleItemView::selectedRowCount(), QAccessibleItemView::selectedRows(), QAccessibleTable2::selectRow(), QAccessibleTree::selectRow(), QAccessibleItemView::selectRow(), QTableViewPrivate::selectRow(), QSidebar::selectUrl(), QCompleterPrivate::setCurrentIndex(), QListWidget::setCurrentRow(), QInputDialogPrivate::setInputWidget(), QListWidget::setItemSelected(), QTableWidget::setItemSelected(), QTreeWidget::setItemSelected(), QInputDialogPrivate::setListViewText(), QCompleter::setPopup(), QTableWidget::setRangeSelected(), QColumnView::setRootIndex(), QTreeView::setSelection(), QColumnView::setSelectionModel(), setSelectionModel(), QAbstractItemViewPrivate::shouldEdit(), QComboBox::showPopup(), QAccessibleItemRow::state(), QAccessibleTable2Cell::state(), QAccessibleTable2::unselectColumn(), QAccessibleItemView::unselectColumn(), QAccessibleTable2::unselectRow(), QAccessibleItemView::unselectRow(), and QCalendarWidgetPrivate::updateCurrentPage().

824 {
825  Q_D(const QAbstractItemView);
826  return d->selectionModel;
827 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setAlternatingRowColors()

void QAbstractItemView::setAlternatingRowColors ( bool  enable)

Definition at line 1586 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

1587 {
1589  d->alternatingColors = enable;
1590  if (isVisible())
1591  d->viewport->update();
1592 }
double d
Definition: qnumeric_p.h:62
bool isVisible() const
Definition: qwidget.h:1005
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setAutoScroll()

void QAbstractItemView::setAutoScroll ( bool  enable)

Definition at line 1382 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

1383 {
1385  d->autoScroll = enable;
1386 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setAutoScrollMargin()

void QAbstractItemView::setAutoScrollMargin ( int  margin)

Definition at line 1405 of file qabstractitemview.cpp.

1406 {
1408  d->autoScrollMargin = margin;
1409 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setCurrentIndex

void QAbstractItemView::setCurrentIndex ( const QModelIndex index)
slot

Sets the current item to be the item at index.

Unless the current selection mode is QAbstractItemView::NoSelection, the item is also be 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 1095 of file qabstractitemview.cpp.

Referenced by QColumnViewPrivate::_q_changeCurrentColumn(), QColumnViewPrivate::closeColumns(), QAccessibleItemRow::doAction(), QInputDialogPrivate::ensureListView(), QComboBoxPrivateContainer::eventFilter(), QSidebar::init(), keyboardSearch(), QComboBoxPrivate::keyboardSearchString(), QAccessibleItemRow::navigate(), rowsAboutToBeRemoved(), QTableWidget::setCurrentCell(), QFontListView::setCurrentItem(), QTableWidget::setCurrentItem(), QTreeWidget::setCurrentItem(), and QComboBoxPrivate::~QComboBoxPrivate().

1096 {
1098  if (d->selectionModel && (!index.isValid() || d->isIndexEnabled(index))) {
1099  QItemSelectionModel::SelectionFlags command = selectionCommand(index, 0);
1100  d->selectionModel->setCurrentIndex(index, command);
1101  d->currentIndexSet = true;
1102  if ((command & QItemSelectionModel::Current) == 0)
1103  d->pressedPosition = visualRect(currentIndex()).center() + d->offset();
1104  }
1105 }
double d
Definition: qnumeric_p.h:62
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
#define Q_D(Class)
Definition: qglobal.h:2482
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event=0) const
Returns the SelectionFlags to be used when updating a selection with to include the index specified...
QModelIndex currentIndex() const
Returns the model index of the current item.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setDefaultDropAction()

void QAbstractItemView::setDefaultDropAction ( Qt::DropAction  dropAction)

Definition at line 1559 of file qabstractitemview.cpp.

1560 {
1562  d->defaultDropAction = dropAction;
1563 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setDirtyRegion()

void QAbstractItemView::setDirtyRegion ( const QRegion region)
protected

Marks the given region as dirty and schedules it to be updated.

Since
4.1

You only need to call this function if you are implementing your own view subclass.

See also
scrollDirtyRegion(), dirtyRegionOffset()

Definition at line 3844 of file qabstractitemview.cpp.

3845 {
3847  d->setDirtyRegion(region);
3848 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setDragDropMode()

void QAbstractItemView::setDragDropMode ( DragDropMode  behavior)

Definition at line 1515 of file qabstractitemview.cpp.

Referenced by QSidebar::init(), QFileDialogListView::init(), QFileDialogTreeView::init(), and QColumnView::initializeColumn().

1516 {
1518  d->dragDropMode = behavior;
1519  setDragEnabled(behavior == DragOnly || behavior == DragDrop || behavior == InternalMove);
1520  setAcceptDrops(behavior == DropOnly || behavior == DragDrop || behavior == InternalMove);
1521 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
void setDragEnabled(bool enable)
The QAbstractItemView class provides the basic functionality for item view classes.
void setAcceptDrops(bool on)
Definition: qwidget.cpp:3534

◆ setDragDropOverwriteMode()

void QAbstractItemView::setDragDropOverwriteMode ( bool  overwrite)

Definition at line 1352 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

1353 {
1355  d->overwrite = overwrite;
1356 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setDragEnabled()

void QAbstractItemView::setDragEnabled ( bool  enable)

Definition at line 1470 of file qabstractitemview.cpp.

Referenced by setDragDropMode(), QListView::setMovement(), and QListView::setViewMode().

1471 {
1473  d->dragEnabled = enable;
1474 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setDropIndicatorShown()

void QAbstractItemView::setDropIndicatorShown ( bool  enable)

Definition at line 1448 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

1449 {
1451  d->showDropIndicator = enable;
1452 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setEditTriggers()

void QAbstractItemView::setEditTriggers ( EditTriggers  triggers)

Definition at line 1261 of file qabstractitemview.cpp.

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

1262 {
1264  d->editTriggers = actions;
1265 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
QList< QAction * > actions() const
Returns the (possibly empty) list of this widget&#39;s actions.
Definition: qwidget.cpp:3407

◆ setHorizontalScrollMode()

void QAbstractItemView::setHorizontalScrollMode ( ScrollMode  mode)

Definition at line 1314 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

1315 {
1317  d->horizontalScrollMode = mode;
1318  updateGeometries(); // update the scroll bars
1319 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.

◆ setHorizontalStepsPerItem()

void QAbstractItemView::setHorizontalStepsPerItem ( int  steps)
protected

Sets the horizontal scroll bar's steps per item to steps.

This is the number of steps used by the horizontal scroll bar to represent the width of an item.

Note that if the view has a horizontal header, the item steps will be ignored and the header section size will be used instead.

See also
horizontalStepsPerItem() setVerticalStepsPerItem()

Definition at line 2966 of file qabstractitemview.cpp.

2967 {
2968  Q_UNUSED(steps)
2969  // do nothing
2970 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setIconSize()

void QAbstractItemView::setIconSize ( const QSize size)

Definition at line 1610 of file qabstractitemview.cpp.

Referenced by QSidebar::init(), QColumnView::initializeColumn(), and QComboBox::setIconSize().

1611 {
1613  if (size == d->iconSize)
1614  return;
1615  d->iconSize = size;
1616  d->doDelayedItemsLayout();
1617 }
double d
Definition: qnumeric_p.h:62
QSize size() const
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setIndexWidget()

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.

Since
4.1

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

The given widget's 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 QItemDelegate instead.

See also
{Delegate Classes}

Definition at line 3246 of file qabstractitemview.cpp.

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

3247 {
3249  if (!d->isIndexValid(index))
3250  return;
3251  if (QWidget *oldWidget = indexWidget(index)) {
3252  d->persistent.remove(oldWidget);
3253  d->removeEditor(oldWidget);
3254  oldWidget->deleteLater();
3255  }
3256  if (widget) {
3257  widget->setParent(viewport());
3258  d->persistent.insert(widget);
3259  d->addEditor(index, widget, true);
3260  widget->show();
3261  dataChanged(index, index); // update the geometry
3262  if (!d->delayedPendingLayout)
3263  widget->setGeometry(visualRect(index));
3264  }
3265 }
double d
Definition: qnumeric_p.h:62
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * indexWidget(const QModelIndex &index) const
Returns the widget for the item at the given index.
QWidget * viewport() const
Returns the viewport widget.
void show()
Shows the widget and its child widgets.
The QAbstractItemView class provides the basic functionality for item view classes.
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This slot is called when items are changed in the model.

◆ 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 QAbstractItemDelegate::closeEditor() signal, and attempt to access, modify or close an editor that has already been closed.
See also
itemDelegate()

Definition at line 844 of file qabstractitemview.cpp.

Referenced by QSidebar::init(), QColumnView::initializeColumn(), QComboBox::setItemDelegate(), and QCompleter::setPopup().

845 {
847  if (delegate == d->itemDelegate)
848  return;
849 
850  if (d->itemDelegate) {
851  if (d->delegateRefCount(d->itemDelegate) == 1) {
854  disconnect(d->itemDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));
855  disconnect(d->itemDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()));
856  }
857  }
858 
859  if (delegate) {
860  if (d->delegateRefCount(delegate) == 0) {
863  connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));
864  qRegisterMetaType<QModelIndex>("QModelIndex");
865  connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection);
866  }
867  }
868  d->itemDelegate = delegate;
869  viewport()->update();
870 }
double d
Definition: qnumeric_p.h:62
virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
Closes the given editor, and releases it.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual void doItemsLayout()
This function is intended to lay out the items in the view.
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void commitData(QWidget *editor)
Commit the data in the editor to the model.
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QWidget * viewport() const
Returns the viewport widget.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
EndEditHint
This enum describes the different hints that the delegate can give to the model and view components t...

◆ setItemDelegateForColumn()

void QAbstractItemView::setItemDelegateForColumn ( int  column,
QAbstractItemDelegate delegate 
)

Sets the given item delegate used by this view and model for the given column.

Since
4.2

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 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 981 of file qabstractitemview.cpp.

982 {
984  if (QAbstractItemDelegate *columnDelegate = d->columnDelegates.value(column, 0)) {
985  if (d->delegateRefCount(columnDelegate) == 1) {
988  disconnect(columnDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));
989  }
990  d->columnDelegates.remove(column);
991  }
992  if (delegate) {
993  if (d->delegateRefCount(delegate) == 0) {
996  connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));
997  }
998  d->columnDelegates.insert(column, delegate);
999  }
1000  viewport()->update();
1001 }
double d
Definition: qnumeric_p.h:62
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
Closes the given editor, and releases it.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void commitData(QWidget *editor)
Commit the data in the editor to the model.
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QWidget * viewport() const
Returns the viewport widget.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
The QAbstractItemView class provides the basic functionality for item view classes.
EndEditHint
This enum describes the different hints that the delegate can give to the model and view components t...

◆ setItemDelegateForRow()

void QAbstractItemView::setItemDelegateForRow ( int  row,
QAbstractItemDelegate delegate 
)

Sets the given item delegate used by this view and model for the given row.

Since
4.2

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 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 918 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

919 {
921  if (QAbstractItemDelegate *rowDelegate = d->rowDelegates.value(row, 0)) {
922  if (d->delegateRefCount(rowDelegate) == 1) {
925  disconnect(rowDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));
926  }
927  d->rowDelegates.remove(row);
928  }
929  if (delegate) {
930  if (d->delegateRefCount(delegate) == 0) {
933  connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*)));
934  }
935  d->rowDelegates.insert(row, delegate);
936  }
937  viewport()->update();
938 }
double d
Definition: qnumeric_p.h:62
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
Closes the given editor, and releases it.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void commitData(QWidget *editor)
Commit the data in the editor to the model.
void update()
Updates the widget unless updates are disabled or the widget is hidden.
Definition: qwidget.cpp:10883
QWidget * viewport() const
Returns the viewport widget.
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
The QAbstractItemView class provides the basic functionality for item view classes.
EndEditHint
This enum describes the different hints that the delegate can give to the model and view components t...

◆ 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;

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 QTreeWidget, QTableWidget, QListWidget, QHeaderView, QTreeView, QColumnView, and QTableView.

Definition at line 691 of file qabstractitemview.cpp.

Referenced by QListWidget::addItems(), QInputDialogPrivate::ensureListView(), QSidebar::init(), QColumnView::initializeColumn(), QFontListView::QFontListView(), QTableView::setModel(), QColumnView::setModel(), QTreeView::setModel(), QHeaderView::setModel(), QCompleter::setPopup(), and QComboBox::setView().

692 {
694  if (model == d->model)
695  return;
696  if (d->model && d->model != QAbstractItemModelPrivate::staticEmptyModel()) {
697  disconnect(d->model, SIGNAL(destroyed()),
698  this, SLOT(_q_modelDestroyed()));
701  disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
702  this, SLOT(_q_headerDataChanged()));
703  disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
704  this, SLOT(rowsInserted(QModelIndex,int,int)));
706  this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));
707  disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
708  this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
709  disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
710  this, SLOT(_q_rowsInserted(QModelIndex,int,int)));
711  disconnect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
712  this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
713  disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
714  this, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
715  disconnect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)),
716  this, SLOT(_q_columnsInserted(QModelIndex,int,int)));
717 
718  disconnect(d->model, SIGNAL(modelReset()), this, SLOT(reset()));
719  disconnect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));
720  }
721  d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel());
722 
723  // These asserts do basic sanity checking of the model
724  Q_ASSERT_X(d->model->index(0,0) == d->model->index(0,0),
725  "QAbstractItemView::setModel",
726  "A model should return the exact same index "
727  "(including its internal id/pointer) when asked for it twice in a row.");
728  Q_ASSERT_X(!d->model->index(0,0).parent().isValid(),
729  "QAbstractItemView::setModel",
730  "The parent of a top level index should be invalid");
731 
733  connect(d->model, SIGNAL(destroyed()),
734  this, SLOT(_q_modelDestroyed()));
737  connect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
738  this, SLOT(_q_headerDataChanged()));
739  connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
740  this, SLOT(rowsInserted(QModelIndex,int,int)));
741  connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
742  this, SLOT(_q_rowsInserted(QModelIndex,int,int)));
743  connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
744  this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));
745  connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
746  this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
747  connect(d->model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
748  this, SLOT(_q_columnsAboutToBeRemoved(QModelIndex,int,int)));
749  connect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
750  this, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
751  connect(d->model, SIGNAL(columnsInserted(QModelIndex,int,int)),
752  this, SLOT(_q_columnsInserted(QModelIndex,int,int)));
753 
754  connect(d->model, SIGNAL(modelReset()), this, SLOT(reset()));
755  connect(d->model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged()));
756  }
757 
758  QItemSelectionModel *selection_model = new QItemSelectionModel(d->model, this);
759  connect(d->model, SIGNAL(destroyed()), selection_model, SLOT(deleteLater()));
760  setSelectionModel(selection_model);
761 
762  reset(); // kill editors, set new root and do layout
763 }
double d
Definition: qnumeric_p.h:62
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
This slot is called when rows are about to be removed.
static QAbstractItemModel * staticEmptyModel()
The QItemSelectionModel class keeps track of a view&#39;s selected items.
virtual void setSelectionModel(QItemSelectionModel *selectionModel)
Sets the current selection model to the given selectionModel.
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
virtual void reset()
Reset the internal state of the view.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
The QAbstractItemView class provides the basic functionality for item view classes.
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
The QModelIndex class is used to locate data in a data model.
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
This slot is called when rows are inserted.
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This slot is called when items are changed in the model.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
Orientation
Definition: qnamespace.h:174
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ setRootIndex

void QAbstractItemView::setRootIndex ( const QModelIndex index)
virtualslot

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

See also
rootIndex()

Reimplemented in QListView, QTreeView, QColumnView, and QTableView.

Definition at line 1159 of file qabstractitemview.cpp.

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

1160 {
1162  if (index.isValid() && index.model() != d->model) {
1163  qWarning("QAbstractItemView::setRootIndex failed : index must be from the currently set model");
1164  return;
1165  }
1166  d->root = index;
1167  d->doDelayedItemsLayout();
1168 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
Q_CORE_EXPORT void qWarning(const char *,...)
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
quint16 index

◆ 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 QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

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

◆ setSelectionBehavior()

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

Definition at line 1069 of file qabstractitemview.cpp.

Referenced by QFileDialogListView::init(), QFileDialogTreeView::init(), QColumnView::initializeColumn(), and QCompleter::popup().

1070 {
1072  d->selectionBehavior = behavior;
1073 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setSelectionMode()

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

Definition at line 1044 of file qabstractitemview.cpp.

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

1045 {
1047  d->selectionMode = mode;
1048 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ 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 QTreeWidget, QTreeView, QColumnView, and QTableView.

Definition at line 788 of file qabstractitemview.cpp.

Referenced by QColumnViewPrivate::_q_changeCurrentColumn(), setModel(), QTableView::setSelectionModel(), QColumnView::setSelectionModel(), and QTreeView::setSelectionModel().

789 {
790  // ### if the given model is null, we should use the original selection model
791  Q_ASSERT(selectionModel);
793 
794  if (selectionModel->model() != d->model) {
795  qWarning("QAbstractItemView::setSelectionModel() failed: "
796  "Trying to set a selection model, which works on "
797  "a different model than the view.");
798  return;
799  }
800 
801  if (d->selectionModel) {
806  }
807 
808  d->selectionModel = selectionModel;
809 
810  if (d->selectionModel) {
815  }
816 }
double d
Definition: qnumeric_p.h:62
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QItemSelectionModel * selectionModel() const
Returns the current selection model.
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
Q_CORE_EXPORT void qWarning(const char *,...)
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This slot is called when the selection is changed.
The QAbstractItemView class provides the basic functionality for item view classes.
The QItemSelection class manages information about selected items in a model.
The QModelIndex class is used to locate data in a data model.
const QAbstractItemModel * model() const
Returns the item model operated on by the selection model.

◆ setState()

void QAbstractItemView::setState ( State  state)
protected

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

See also
state()

Definition at line 3798 of file qabstractitemview.cpp.

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

3799 {
3801  d->state = state;
3802 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
State state() const
Returns the item view&#39;s state.

◆ setTabKeyNavigation()

void QAbstractItemView::setTabKeyNavigation ( bool  enable)

Definition at line 1425 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn(), and QCalendarView::QCalendarView().

1426 {
1428  d->tabKeyNavigation = enable;
1429 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setTextElideMode()

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

Definition at line 1635 of file qabstractitemview.cpp.

Referenced by QFileDialogTreeView::init(), and QColumnView::initializeColumn().

1636 {
1638  d->textElideMode = mode;
1639 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.

◆ setVerticalScrollMode()

void QAbstractItemView::setVerticalScrollMode ( ScrollMode  mode)

Definition at line 1285 of file qabstractitemview.cpp.

Referenced by QColumnView::initializeColumn().

1286 {
1288  if (mode == d->verticalScrollMode)
1289  return;
1290  QModelIndex topLeft = indexAt(QPoint(0, 0));
1291  d->verticalScrollMode = mode;
1292  updateGeometries(); // update the scroll bars
1294 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
The QAbstractItemView class provides the basic functionality for item view classes.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QModelIndex class is used to locate data in a data model.
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.

◆ setVerticalStepsPerItem()

void QAbstractItemView::setVerticalStepsPerItem ( int  steps)
protected

Sets the vertical scroll bar's steps per item to steps.

This is the number of steps used by the vertical scroll bar to represent the height of an item.

Note that if the view has a vertical header, the item steps will be ignored and the header section size will be used instead.

See also
verticalStepsPerItem() setHorizontalStepsPerItem()

Definition at line 3001 of file qabstractitemview.cpp.

3002 {
3003  Q_UNUSED(steps)
3004  // do nothing
3005 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ showDropIndicator()

bool QAbstractItemView::showDropIndicator ( ) const

◆ 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 QTreeView, and QTableView.

Definition at line 3157 of file qabstractitemview.cpp.

3158 {
3159  Q_D(const QAbstractItemView);
3160 
3161  if (column < 0 || column >= d->model->columnCount(d->root))
3162  return -1;
3163 
3164  ensurePolished();
3165 
3166  QStyleOptionViewItemV4 option = d->viewOptionsV4();
3167  int width = 0;
3168  int rows = d->model->rowCount(d->root);
3170  for (int r = 0; r < rows; ++r) {
3171  index = d->model->index(r, column, d->root);
3172  if (QWidget *editor = d->editorForIndex(index).widget.data())
3173  width = qMax(width, editor->sizeHint().width());
3174  int hint = d->delegateForIndex(index)->sizeHint(option, index).width();
3175  width = qMax(width, hint);
3176  }
3177  return width;
3178 }
double d
Definition: qnumeric_p.h:62
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
#define Q_D(Class)
Definition: qglobal.h:2482
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int width() const
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
quint16 index

◆ 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 3102 of file qabstractitemview.cpp.

Referenced by QSidebar::sizeHint().

3103 {
3104  Q_D(const QAbstractItemView);
3105  if (!d->isIndexValid(index) || !d->itemDelegate)
3106  return QSize();
3107  return d->delegateForIndex(index)->sizeHint(d->viewOptionsV4(), index);
3108 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
quint16 index
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ 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 3126 of file qabstractitemview.cpp.

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

3127 {
3128  Q_D(const QAbstractItemView);
3129 
3130  if (row < 0 || row >= d->model->rowCount(d->root))
3131  return -1;
3132 
3133  ensurePolished();
3134 
3135  QStyleOptionViewItemV4 option = d->viewOptionsV4();
3136  int height = 0;
3137  int colCount = d->model->columnCount(d->root);
3139  for (int c = 0; c < colCount; ++c) {
3140  index = d->model->index(row, c, d->root);
3141  if (QWidget *editor = d->editorForIndex(index).widget.data())
3142  height = qMax(height, editor->height());
3143  int hint = d->delegateForIndex(index)->sizeHint(option, index).height();
3144  height = qMax(height, hint);
3145  }
3146  return height;
3147 }
double d
Definition: qnumeric_p.h:62
unsigned char c[8]
Definition: qnumeric_p.h:62
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
quint16 index

◆ startAutoScroll()

void QAbstractItemView::startAutoScroll ( )
protected
Warning
This function is not part of the public interface.

Definition at line 3884 of file qabstractitemview.cpp.

Referenced by dragMoveEvent().

3885 {
3886  d_func()->startAutoScroll();
3887 }

◆ startDrag()

void QAbstractItemView::startDrag ( Qt::DropActions  supportedActions)
protectedvirtual

Starts a drag by calling drag->exec() using the given supportedActions.

Reimplemented in QListView.

Definition at line 3709 of file qabstractitemview.cpp.

Referenced by mouseMoveEvent(), and QListView::startDrag().

3710 {
3712  QModelIndexList indexes = d->selectedDraggableIndexes();
3713  if (indexes.count() > 0) {
3714  QMimeData *data = d->model->mimeData(indexes);
3715  if (!data)
3716  return;
3717  QRect rect;
3718  QPixmap pixmap = d->renderToPixmap(indexes, &rect);
3719  rect.adjust(horizontalOffset(), verticalOffset(), 0, 0);
3720  QDrag *drag = new QDrag(this);
3721  drag->setPixmap(pixmap);
3722  drag->setMimeData(data);
3723  drag->setHotSpot(d->pressedPosition - rect.topLeft());
3725  if (d->defaultDropAction != Qt::IgnoreAction && (supportedActions & d->defaultDropAction))
3726  defaultDropAction = d->defaultDropAction;
3727  else if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove)
3728  defaultDropAction = Qt::CopyAction;
3729  if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction)
3730  d->clearOrRemove();
3731  }
3732 }
double d
Definition: qnumeric_p.h:62
void setPixmap(const QPixmap &)
Sets pixmap as the pixmap used to represent the data in a drag and drop operation.
Definition: qdrag.cpp:166
The QDrag class provides support for MIME-based drag and drop data transfer.
Definition: qdrag.h:61
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
Definition: qdrag.cpp:142
DragDropMode dragDropMode() const
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Qt::DropAction exec(Qt::DropActions supportedActions=Qt::MoveAction)
Starts the drag and drop operation and returns a value indicating the requested drop action when it i...
Definition: qdrag.cpp:243
Qt::DropAction defaultDropAction() const
#define Q_D(Class)
Definition: qglobal.h:2482
virtual int verticalOffset() const =0
Returns the vertical offset of the view.
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
QWidgetData * data
Definition: qwidget.h:815
virtual int horizontalOffset() const =0
Returns the horizontal offset of the view.
DropAction
Definition: qnamespace.h:1597
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
QRect rect() const
The QAbstractItemView class provides the basic functionality for item view classes.
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
void setHotSpot(const QPoint &hotspot)
Sets the position of the hot spot relative to the top-left corner of the pixmap used to the point spe...
Definition: qdrag.cpp:189
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288

◆ state()

QAbstractItemView::State QAbstractItemView::state ( ) const
protected

◆ stopAutoScroll()

void QAbstractItemView::stopAutoScroll ( )
protected
Warning
This function is not part of the public interface.

Definition at line 3892 of file qabstractitemview.cpp.

Referenced by doAutoScroll(), dragLeaveEvent(), dropEvent(), and mouseMoveEvent().

3893 {
3894  d_func()->stopAutoScroll();
3895 }

◆ tabKeyNavigation()

bool QAbstractItemView::tabKeyNavigation ( ) const

◆ textElideMode()

Qt::TextElideMode QAbstractItemView::textElideMode ( ) const

◆ timerEvent()

void QAbstractItemView::timerEvent ( QTimerEvent event)
protectedvirtual

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

See also
QObject::timerEvent()

Reimplemented from QObject.

Reimplemented in QTreeView, QListView, and QTableView.

Definition at line 2553 of file qabstractitemview.cpp.

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

2554 {
2556  if (event->timerId() == d->fetchMoreTimer.timerId())
2557  d->fetchMore();
2558  else if (event->timerId() == d->delayedReset.timerId())
2559  reset();
2560  else if (event->timerId() == d->autoScrollTimer.timerId())
2561  doAutoScroll();
2562  else if (event->timerId() == d->updateTimer.timerId())
2563  d->updateDirtyRegion();
2564  else if (event->timerId() == d->delayedEditing.timerId()) {
2565  d->delayedEditing.stop();
2566  edit(currentIndex());
2567  } else if (event->timerId() == d->delayedLayout.timerId()) {
2568  d->delayedLayout.stop();
2569  if (isVisible()) {
2570  d->interruptDelayedItemsLayout();
2571  doItemsLayout();
2572  const QModelIndex current = currentIndex();
2573  if (current.isValid() && d->state == QAbstractItemView::EditingState)
2574  scrollTo(current);
2575  }
2576  } else if (event->timerId() == d->delayedAutoScroll.timerId()) {
2577  d->delayedAutoScroll.stop();
2578  //end of the timer: if the current item is still the same as the one when the mouse press occurred
2579  //we only get here if there was no double click
2580  if (d->pressedIndex.isValid() && d->pressedIndex == currentIndex())
2581  scrollTo(d->pressedIndex);
2582  }
2583 }
double d
Definition: qnumeric_p.h:62
bool isVisible() const
Definition: qwidget.h:1005
virtual void doItemsLayout()
This function is intended to lay out the items in the view.
#define Q_D(Class)
Definition: qglobal.h:2482
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
virtual void reset()
Reset the internal state of the view.
QModelIndex currentIndex() const
Returns the model index of the current item.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
void edit(const QModelIndex &index)
Starts editing the item corresponding to the given index if it is editable.

◆ update

void QAbstractItemView::update ( const QModelIndex index)
slot

Updates the area occupied by the given index.

Warning
This function is not part of the public interface.
Since
4.3

Definition at line 3329 of file qabstractitemview.cpp.

3330 {
3332  if (index.isValid()) {
3333  const QRect rect = visualRect(index);
3334  //this test is important for peformance reason
3335  //For example in dataChanged we simply update all the cells without checking
3336  //it can be a major bottleneck to update rects that aren't even part of the viewport
3337  if (d->viewport->rect().intersects(rect))
3338  d->viewport->update(rect);
3339  }
3340 }
double d
Definition: qnumeric_p.h:62
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
#define Q_D(Class)
Definition: qglobal.h:2482
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QRect rect() const
The QAbstractItemView class provides the basic functionality for item view classes.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ updateEditorData

void QAbstractItemView::updateEditorData ( )
protectedvirtualslot

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

Warning
This function is not part of the public interface.

Definition at line 2731 of file qabstractitemview.cpp.

2732 {
2734  d->updateEditorData(QModelIndex(), QModelIndex());
2735 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.

◆ updateEditorGeometries

void QAbstractItemView::updateEditorGeometries ( )
protectedvirtualslot

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

Warning
This function is not part of the public interface.

Definition at line 2744 of file qabstractitemview.cpp.

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

2745 {
2747  if(d->editorIndexHash.isEmpty())
2748  return;
2749  QStyleOptionViewItemV4 option = d->viewOptionsV4();
2750  QEditorIndexHash::iterator it = d->editorIndexHash.begin();
2751  QWidgetList editorsToRelease;
2752  QWidgetList editorsToHide;
2753  while (it != d->editorIndexHash.end()) {
2754  QModelIndex index = it.value();
2755  QWidget *editor = it.key();
2756  if (index.isValid() && editor) {
2757  option.rect = visualRect(index);
2758  if (option.rect.isValid()) {
2759  editor->show();
2760  QAbstractItemDelegate *delegate = d->delegateForIndex(index);
2761  if (delegate)
2762  delegate->updateEditorGeometry(editor, option, index);
2763  } else {
2764  editorsToHide << editor;
2765  }
2766  ++it;
2767  } else {
2768  d->indexEditorHash.remove(it.value());
2769  it = d->editorIndexHash.erase(it);
2770  editorsToRelease << editor;
2771  }
2772  }
2773 
2774  //we hide and release the editor outside of the loop because it might change the focus and try
2775  //to change the editors hashes.
2776  for (int i = 0; i < editorsToHide.count(); ++i) {
2777  editorsToHide.at(i)->hide();
2778  }
2779  for (int i = 0; i < editorsToRelease.count(); ++i) {
2780  d->releaseEditor(editorsToRelease.at(i));
2781  }
2782 }
double d
Definition: qnumeric_p.h:62
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
Updates the geometry of the editor for the item with the given index, according to the rectangle spec...
#define it(className, varName)
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void show()
Shows the widget and its child widgets.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemView class provides the basic functionality for item view classes.
The QModelIndex class is used to locate data in a data model.
quint16 index
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ updateGeometries

void QAbstractItemView::updateGeometries ( )
protectedvirtualslot

Updates the geometry of the child widgets of the view.

Since
4.4

Reimplemented in QHeaderView, QTreeView, QListView, and QTableView.

Definition at line 2792 of file qabstractitemview.cpp.

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

2793 {
2795  d_func()->fetchMoreTimer.start(0, this); //fetch more later
2796 }
virtual void updateEditorGeometries()
Updates the geometry of the open editor widgets in the view.

◆ 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 QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

Referenced by startDrag().

◆ verticalScrollbarAction

void QAbstractItemView::verticalScrollbarAction ( int  action)
protectedvirtualslot
Warning
This function is not part of the public interface.

Reimplemented in QTableView.

Definition at line 2827 of file qabstractitemview.cpp.

Referenced by QTableView::verticalScrollbarAction().

2828 {
2829  //do nothing
2830 }

◆ verticalScrollbarValueChanged

void QAbstractItemView::verticalScrollbarValueChanged ( int  value)
protectedvirtualslot
Warning
This function is not part of the public interface.

Definition at line 2801 of file qabstractitemview.cpp.

2802 {
2804  if (verticalScrollBar()->maximum() == value && d->model->canFetchMore(d->root))
2805  d->model->fetchMore(d->root);
2806  QPoint posInVp = viewport()->mapFromGlobal(QCursor::pos());
2807  if (viewport()->rect().contains(posInVp))
2808  d->checkMouseMove(posInVp);
2809 }
double d
Definition: qnumeric_p.h:62
QScrollBar * verticalScrollBar() const
Returns the vertical scroll bar.
#define Q_D(Class)
Definition: qglobal.h:2482
QWidget * viewport() const
Returns the viewport widget.
QRect rect() const
The QAbstractItemView class provides the basic functionality for item view classes.
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310

◆ verticalScrollMode()

ScrollMode QAbstractItemView::verticalScrollMode ( ) const

◆ verticalStepsPerItem()

int QAbstractItemView::verticalStepsPerItem ( ) const
protected

Returns the vertical scroll bar's steps per item.

See also
setVerticalStepsPerItem() horizontalStepsPerItem()

Definition at line 3016 of file qabstractitemview.cpp.

3017 {
3018  return 1;
3019 }

◆ viewOptions()

QStyleOptionViewItem QAbstractItemView::viewOptions ( ) const
protectedvirtual

Returns a QStyleOptionViewItem structure populated with the view's palette, font, state, alignments etc.

Reimplemented in QListView, QTableView, and QComboBoxListView.

Definition at line 3739 of file qabstractitemview.cpp.

Referenced by QTreeView::drawBranches(), QTableView::viewOptions(), and QListView::viewOptions().

3740 {
3741  Q_D(const QAbstractItemView);
3742  QStyleOptionViewItem option;
3743  option.init(this);
3744  option.state &= ~QStyle::State_MouseOver;
3745  option.font = font();
3746 
3747 #ifndef Q_WS_MAC
3748  // On mac the focus appearance follows window activation
3749  // not widget activation
3750  if (!hasFocus())
3751  option.state &= ~QStyle::State_Active;
3752 #endif
3753 
3754  option.state &= ~QStyle::State_HasFocus;
3755  if (d->iconSize.isValid()) {
3756  option.decorationSize = d->iconSize;
3757  } else {
3758  int pm = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
3759  option.decorationSize = QSize(pm, pm);
3760  }
3764  option.textElideMode = d->textElideMode;
3765  option.rect = QRect();
3767  return option;
3768 }
double d
Definition: qnumeric_p.h:62
QFont font
the font used for the item
Definition: qstyleoption.h:552
Qt::Alignment decorationAlignment
the alignment of the decoration for the item
Definition: qstyleoption.h:548
QStyle::State state
the style flags that are used when drawing the control
Definition: qstyleoption.h:88
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
Position decorationPosition
the position of the decoration for the item
Definition: qstyleoption.h:550
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
Qt::TextElideMode textElideMode
where ellipsis should be added for text that is too long to fit into an item
Definition: qstyleoption.h:549
void init(const QWidget *w)
Use initFrom(widget) instead.
bool hasFocus() const
Definition: qwidget.cpp:6583
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
bool showDecorationSelected
whether the decoration should be highlighted on selected items
Definition: qstyleoption.h:553
The QAbstractItemView class provides the basic functionality for item view classes.
Qt::Alignment displayAlignment
the alignment of the display value for the item
Definition: qstyleoption.h:547
QSize decorationSize
the size of the decoration for the item
Definition: qstyleoption.h:551
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const QFont & font() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
QRect rect
the area that should be used for various calculations and painting
Definition: qstyleoption.h:90

◆ 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)
protectedvirtual

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.

Reimplemented from QAbstractScrollArea.

Reimplemented in QTreeView, and QHeaderView.

Definition at line 1717 of file qabstractitemview.cpp.

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

1718 {
1720  switch (event->type()) {
1721  case QEvent::HoverMove:
1722  case QEvent::HoverEnter:
1723  d->setHoverIndex(indexAt(static_cast<QHoverEvent*>(event)->pos()));
1724  break;
1725  case QEvent::HoverLeave:
1726  d->setHoverIndex(QModelIndex());
1727  break;
1728  case QEvent::Enter:
1729  d->viewportEnteredNeeded = true;
1730  break;
1731  case QEvent::Leave:
1732  #ifndef QT_NO_STATUSTIP
1733  if (d->shouldClearStatusTip && d->parent) {
1734  QString empty;
1735  QStatusTipEvent tip(empty);
1736  QApplication::sendEvent(d->parent, &tip);
1737  d->shouldClearStatusTip = false;
1738  }
1739  #endif
1740  d->enteredIndex = QModelIndex();
1741  break;
1742  case QEvent::ToolTip:
1744  case QEvent::WhatsThis: {
1745  QHelpEvent *he = static_cast<QHelpEvent*>(event);
1746  const QModelIndex index = indexAt(he->pos());
1747  QStyleOptionViewItemV4 option = d->viewOptionsV4();
1748  option.rect = visualRect(index);
1749  option.state |= (index == currentIndex() ? QStyle::State_HasFocus : QStyle::State_None);
1750  bool retval = false;
1751  // ### Qt 5: make this a normal function call to a virtual function
1752  QMetaObject::invokeMethod(d->delegateForIndex(index), "helpEvent",
1753  Q_RETURN_ARG(bool, retval),
1754  Q_ARG(QHelpEvent *, he),
1755  Q_ARG(QAbstractItemView *, this),
1756  Q_ARG(QStyleOptionViewItem, option),
1757  Q_ARG(QModelIndex, index));
1758  return retval;
1759  }
1760  case QEvent::FontChange:
1761  d->doDelayedItemsLayout(); // the size of the items will change
1762  break;
1765  d->viewport->update();
1766  break;
1767  default:
1768  break;
1769  }
1770  return QAbstractScrollArea::viewportEvent(event);
1771 }
QPoint pos() const
double d
Definition: qnumeric_p.h:62
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
The QStyleOptionViewItemV4 class is used to describe the parameters necessary for drawing a frame in ...
Definition: qstyleoption.h:609
#define Q_ARG(type, data)
Definition: qobjectdefs.h:246
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
#define Q_RETURN_ARG(type, data)
Definition: qobjectdefs.h:247
QModelIndex currentIndex() const
Returns the model index of the current item.
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
virtual bool viewportEvent(QEvent *)
The main event handler for the scrolling area (the viewport() widget).
The QAbstractItemView class provides the basic functionality for item view classes.
The QStatusTipEvent class provides an event that is used to show messages in a status bar...
Definition: qevent.h:606
The QModelIndex class is used to locate data in a data model.
quint16 index
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
bool event(QEvent *event)
Reimplemented Function
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...
Definition: qevent.h:597

◆ 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 QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

Referenced by dragMoveEvent(), inputMethodQuery(), keyPressEvent(), mousePressEvent(), openPersistentEditor(), QAccessibleItemRow::rect(), QAccessibleTable2Cell::rect(), setCurrentIndex(), setIndexWidget(), QComboBox::showPopup(), update(), updateEditorGeometries(), and viewportEvent().

◆ 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 QHeaderView, QTreeView, QListView, QTableView, QColumnViewPreviewColumn, and QColumnView.

Referenced by selectionChanged().

Friends and Related Functions

◆ QAccessibleItemRow

friend class QAccessibleItemRow
friend

Definition at line 365 of file qabstractitemview.h.

◆ QListModeViewBase

friend class QListModeViewBase
friend

Definition at line 366 of file qabstractitemview.h.

Referenced by QListView::setViewMode().

◆ QListViewPrivate

friend class QListViewPrivate
friend

Definition at line 367 of file qabstractitemview.h.

◆ QTreeViewPrivate

friend class QTreeViewPrivate
friend

Definition at line 364 of file qabstractitemview.h.

Properties

◆ alternatingRowColors

bool QAbstractItemView::alternatingRowColors
private

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 79 of file qabstractitemview.h.

◆ autoScroll

QAbstractItemView::autoScroll
private

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 68 of file qabstractitemview.h.

Referenced by focusInEvent(), mousePressEvent(), and QAbstractItemViewPrivate::shouldAutoScroll().

◆ autoScrollMargin

int QAbstractItemView::autoScrollMargin
private

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 69 of file qabstractitemview.h.

◆ defaultDropAction

Qt::DropAction QAbstractItemView::defaultDropAction
private

the drop action that will be used by default in QAbstractItemView::drag()

If the property is not set, the drop action is CopyAction when the supported actions support CopyAction.

Since
4.6
See also
showDropIndicator dragDropOverwriteMode

Definition at line 77 of file qabstractitemview.h.

◆ dragDropMode

QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode
private

the drag and drop event the view will act upon

Since
4.2
See also
showDropIndicator dragDropOverwriteMode

Definition at line 76 of file qabstractitemview.h.

◆ dragDropOverwriteMode

bool QAbstractItemView::dragDropOverwriteMode
private

the view's drag and drop behavior

Since
4.2

If its value is true, the selected data will overwrite the existing item data when dropped, while moving the data will clear the item. If its value is false, the selected data will be inserted as a new item when the data is dropped. When the data is moved, the item is removed as well.

The default value is false, as in the QListView and QTreeView subclasses. In the QTableView subclass, on the other hand, the property has been set to true.

Note: This is not intended to prevent overwriting of items. The model's implementation of flags() should do that by not returning Qt::ItemIsDropEnabled.

See also
dragDropMode

Definition at line 75 of file qabstractitemview.h.

◆ dragEnabled

bool QAbstractItemView::dragEnabled
private

whether the view supports dragging of its own items

See also
showDropIndicator DragDropMode dragDropOverwriteMode acceptDrops

Definition at line 74 of file qabstractitemview.h.

◆ editTriggers

QAbstractItemView::EditTriggers QAbstractItemView::editTriggers
private

which actions will initiate item editing

This property is a selection of flags defined by 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 70 of file qabstractitemview.h.

◆ horizontalScrollMode

QAbstractItemView::ScrollMode QAbstractItemView::horizontalScrollMode
private

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.

Definition at line 85 of file qabstractitemview.h.

◆ iconSize

QSize QAbstractItemView::iconSize
private

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 82 of file qabstractitemview.h.

◆ selectionBehavior

QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior
private

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 81 of file qabstractitemview.h.

Referenced by QWindowsVistaStyle::drawPrimitive().

◆ selectionMode

QAbstractItemView::SelectionMode QAbstractItemView::selectionMode
private

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 80 of file qabstractitemview.h.

Referenced by QWindowsVistaStyle::drawControl(), QWindowsVistaStyle::drawPrimitive(), QAccessibleTable2::selectColumn(), QAccessibleTable2::selectRow(), QAccessibleTree::selectRow(), QAccessibleItemRow::state(), QAccessibleItemView::state(), QAccessibleTable2Cell::state(), QAccessibleTable2::unselectColumn(), and QAccessibleTable2::unselectRow().

◆ showDropIndicator

bool QAbstractItemView::showDropIndicator
private

whether the drop indicator is shown when dragging items and dropping.

See also
dragEnabled DragDropMode dragDropOverwriteMode acceptDrops

Definition at line 73 of file qabstractitemview.h.

◆ tabKeyNavigation

bool QAbstractItemView::tabKeyNavigation
private

whether item navigation with tab and backtab is enabled.

Definition at line 71 of file qabstractitemview.h.

◆ textElideMode

Qt::TextElideMode QAbstractItemView::textElideMode
private

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

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

Definition at line 83 of file qabstractitemview.h.

◆ verticalScrollMode

QAbstractItemView::ScrollMode QAbstractItemView::verticalScrollMode
private

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.

Definition at line 84 of file qabstractitemview.h.


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