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

The QListView class provides a list or icon view onto a model. More...

#include <qlistview.h>

+ Inheritance diagram for QListView:
+ Collaboration diagram for QListView:

Public Types

enum  Movement { Static , Free , Snap }
 \value Static The items cannot be moved by the user. More...
 
enum  Flow { LeftToRight , TopToBottom }
 \value LeftToRight The items are laid out in the view from the left to the right. More...
 
enum  ResizeMode { Fixed , Adjust }
 \value Fixed The items will only be laid out the first time the view is shown. More...
 
enum  LayoutMode { SinglePass , Batched }
 \value SinglePass The items are laid out all at once. More...
 
enum  ViewMode { ListMode , IconMode }
 \value ListMode The items are laid out using TopToBottom flow, with Small size and Static movement \value IconMode The items are laid out using LeftToRight flow, with Large size and Free movement More...
 
- Public Types inherited from QAbstractItemView
enum  SelectionMode {
  NoSelection , SingleSelection , MultiSelection , ExtendedSelection ,
  ContiguousSelection
}
 This enum indicates how the view responds to user selections: More...
 
enum  SelectionBehavior { SelectItems , SelectRows , SelectColumns }
 \value SelectItems Selecting single items. More...
 
enum  ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter }
 \value EnsureVisible Scroll to ensure that the item is visible. More...
 
enum  EditTrigger {
  NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 ,
  EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31
}
 This enum describes actions which will initiate item editing. More...
 
enum  ScrollMode { ScrollPerItem , ScrollPerPixel }
 

Signals

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

Public Member Functions

 QListView (QWidget *parent=nullptr)
 Creates a new QListView with the given parent to view a model.
 
 ~QListView ()
 Destroys the view.
 
void setMovement (Movement movement)
 
Movement movement () const
 
void setFlow (Flow flow)
 
Flow flow () const
 
void setWrapping (bool enable)
 
bool isWrapping () const
 
void setResizeMode (ResizeMode mode)
 
ResizeMode resizeMode () const
 
void setLayoutMode (LayoutMode mode)
 
LayoutMode layoutMode () const
 
void setSpacing (int space)
 
int spacing () const
 
void setBatchSize (int batchSize)
 
int batchSize () const
 
void setGridSize (const QSize &size)
 
QSize gridSize () const
 
void setViewMode (ViewMode mode)
 
ViewMode viewMode () const
 
void clearPropertyFlags ()
 Clears the QListView-specific property flags.
 
bool isRowHidden (int row) const
 Returns true if the row is hidden; otherwise returns false.
 
void setRowHidden (int row, bool hide)
 If hide is true, the given row will be hidden; otherwise the row will be shown.
 
void setModelColumn (int column)
 
int modelColumn () const
 
void setUniformItemSizes (bool enable)
 
bool uniformItemSizes () const
 
void setWordWrap (bool on)
 
bool wordWrap () const
 
void setSelectionRectVisible (bool show)
 
bool isSelectionRectVisible () const
 
void setItemAlignment (Qt::Alignment alignment)
 
Qt::Alignment itemAlignment () const
 
QRect visualRect (const QModelIndex &index) const override
 \reimp
 
void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible) override
 \reimp
 
QModelIndex indexAt (const QPoint &p) const override
 \reimp
 
void doItemsLayout () override
 
void reset () override
 
void setRootIndex (const QModelIndex &index) override
 \reimp
 
- Public Member Functions inherited from QAbstractItemView
 QAbstractItemView (QWidget *parent=nullptr)
 Constructs an abstract item view with the given parent.
 
 ~QAbstractItemView ()
 Destroys the view.
 
virtual void setModel (QAbstractItemModel *model)
 Sets the model for the view to present.
 
QAbstractItemModelmodel () const
 Returns the model that this view is presenting.
 
virtual void setSelectionModel (QItemSelectionModel *selectionModel)
 Sets the current selection model to the given selectionModel.
 
QItemSelectionModelselectionModel () const
 Returns the current selection model.
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 Sets the item delegate for this view and its model to delegate.
 
QAbstractItemDelegateitemDelegate () const
 Returns the item delegate used by this view and model.
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
QAbstractItemView::SelectionMode selectionMode () const
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QModelIndex currentIndex () const
 Returns the model index of the current item.
 
QModelIndex rootIndex () const
 Returns the model index of the model's root item.
 
void setEditTriggers (EditTriggers triggers)
 
EditTriggers editTriggers () const
 
void setVerticalScrollMode (ScrollMode mode)
 
ScrollMode verticalScrollMode () const
 
void resetVerticalScrollMode ()
 
void setHorizontalScrollMode (ScrollMode mode)
 
ScrollMode horizontalScrollMode () const
 
void resetHorizontalScrollMode ()
 
void setAutoScroll (bool enable)
 
bool hasAutoScroll () const
 
void setAutoScrollMargin (int margin)
 
int autoScrollMargin () const
 
void setTabKeyNavigation (bool enable)
 
bool tabKeyNavigation () const
 
void setAlternatingRowColors (bool enable)
 
bool alternatingRowColors () const
 
void setIconSize (const QSize &size)
 
QSize iconSize () const
 
void setTextElideMode (Qt::TextElideMode mode)
 
Qt::TextElideMode textElideMode () const
 
virtual void keyboardSearch (const QString &search)
 Moves to and selects the item best matching the string search.
 
QSize sizeHintForIndex (const QModelIndex &index) const
 Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
 
virtual int sizeHintForRow (int row) const
 Returns the height size hint for the specified row or -1 if there is no model.
 
virtual int sizeHintForColumn (int column) const
 Returns the width size hint for the specified column or -1 if there is no model.
 
void openPersistentEditor (const QModelIndex &index)
 Opens a persistent editor on the item at the given index.
 
void closePersistentEditor (const QModelIndex &index)
 Closes the persistent editor for the item at the given index.
 
bool isPersistentEditorOpen (const QModelIndex &index) const
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 
QWidgetindexWidget (const QModelIndex &index) const
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 
virtual QAbstractItemDelegateitemDelegateForIndex (const QModelIndex &index) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 \reimp
 

Protected Member Functions

 QListView (QListViewPrivate &, QWidget *parent=nullptr)
 
bool event (QEvent *e) override
 \reimp
 
void scrollContentsBy (int dx, int dy) override
 \reimp
 
void resizeContents (int width, int height)
 
QSize contentsSize () const
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >()) override
 \reimp
 
void rowsInserted (const QModelIndex &parent, int start, int end) override
 \reimp
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) override
 \reimp
 
void mouseMoveEvent (QMouseEvent *e) override
 \reimp
 
void mouseReleaseEvent (QMouseEvent *e) override
 \reimp
 
void timerEvent (QTimerEvent *e) override
 \reimp
 
void resizeEvent (QResizeEvent *e) override
 \reimp
 
void initViewItemOption (QStyleOptionViewItem *option) const override
 \reimp
 
void paintEvent (QPaintEvent *e) override
 \reimp
 
int horizontalOffset () const override
 \reimp
 
int verticalOffset () const override
 \reimp
 
QModelIndex moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
 \reimp
 
QRect rectForIndex (const QModelIndex &index) const
 Returns the rectangle of the item at position index in the model.
 
void setPositionForIndex (const QPoint &position, const QModelIndex &index)
 
void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command) override
 \reimp
 
QRegion visualRegionForSelection (const QItemSelection &selection) const override
 \reimp
 
QModelIndexList selectedIndexes () const override
 \reimp
 
void updateGeometries () override
 \reimp
 
bool isIndexHidden (const QModelIndex &index) const override
 \reimp
 
void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override
 \reimp
 
void currentChanged (const QModelIndex &current, const QModelIndex &previous) override
 \reimp
 
QSize viewportSizeHint () const override
 
- Protected Member Functions inherited from QAbstractItemView
 QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=nullptr)
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 Starts editing the item at index, creating an editor if necessary, and returns true if the view's \l{State} is now EditingState; otherwise returns false.
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 Returns the SelectionFlags to be used when updating a selection model for the specified index.
 
State state () const
 Returns the item view's state.
 
void setState (State state)
 Sets the item view's state to the given state.
 
void scheduleDelayedItemsLayout ()
 Schedules a layout of the items in the view to be executed when the event processing starts.
 
void executeDelayedItemsLayout ()
 Executes the scheduled layouts without waiting for the event processing to begin.
 
void setDirtyRegion (const QRegion &region)
 
void scrollDirtyRegion (int dx, int dy)
 Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite direction.
 
QPoint dirtyRegionOffset () const
 Returns the offset of the dirty regions in the view.
 
void startAutoScroll ()
 
void stopAutoScroll ()
 
void doAutoScroll ()
 
bool focusNextPrevChild (bool next) override
 \reimp
 
bool event (QEvent *event) override
 \reimp
 
bool viewportEvent (QEvent *event) override
 This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::ToolTip,or a QEvent::WhatsThis.
 
void mousePressEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is pressed while the cursor is inside the widget.
 
void mouseMoveEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse move event is sent to the widget.
 
void mouseReleaseEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is released, after a mouse press event on the widget.
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is double clicked inside the widget.
 
void focusInEvent (QFocusEvent *event) override
 This function is called with the given event when the widget obtains the focus.
 
void focusOutEvent (QFocusEvent *event) override
 This function is called with the given event when the widget loses the focus.
 
void keyPressEvent (QKeyEvent *event) override
 This function is called with the given event when a key event is sent to the widget.
 
void resizeEvent (QResizeEvent *event) override
 This function is called with the given event when a resize event is sent to the widget.
 
void timerEvent (QTimerEvent *event) override
 This function is called with the given event when a timer event is sent to the widget.
 
void inputMethodEvent (QInputMethodEvent *event) override
 \reimp
 
bool eventFilter (QObject *object, QEvent *event) override
 \reimp
 
QSize viewportSizeHint () const override
 

Properties

Movement movement
 whether the items can be moved freely, are snapped to a grid, or cannot be moved at all.
 
Flow flow
 which direction the items layout should flow.
 
bool isWrapping
 whether the items layout should wrap.
 
ResizeMode resizeMode
 whether the items are laid out again when the view is resized.
 
LayoutMode layoutMode
 determines whether the layout of items should happen immediately or be delayed.
 
int spacing
 the space around the items in the layout
 
QSize gridSize
 the size of the layout grid
 
ViewMode viewMode
 the view mode of the QListView.
 
int modelColumn
 the column in the model that is visible
 
bool uniformItemSizes
 whether all items in the listview have the same size
 
int batchSize
 the number of items laid out in each batch if \l layoutMode is set to \l Batched.
 
bool wordWrap
 the item text word-wrapping policy
 
bool selectionRectVisible
 if the selection rectangle should be visible
 
Qt::Alignment itemAlignment
 the alignment of each item in its cell
 
- Properties inherited from QAbstractItemView
bool autoScroll
 whether autoscrolling in drag move events is enabled
 
int autoScrollMargin
 the size of the area when auto scrolling is triggered
 
EditTriggers editTriggers
 which actions will initiate item editing
 
bool tabKeyNavigation
 whether item navigation with tab and backtab is enabled.
 
bool alternatingRowColors
 whether to draw the background using alternating colors
 
SelectionMode selectionMode
 which selection mode the view operates in
 
SelectionBehavior selectionBehavior
 which selection behavior the view uses
 
QSize iconSize
 the size of items' icons
 
Qt::TextElideMode textElideMode
 the position of the "..." in elided text.
 
ScrollMode verticalScrollMode
 how the view scrolls its contents in the vertical direction
 
ScrollMode horizontalScrollMode
 how the view scrolls its contents in the horizontal direction
 

Friends

class QCommonListViewBase
 

Additional Inherited Members

- Public Slots inherited from QAbstractItemView
virtual void selectAll ()
 Selects all items in the view.
 
void edit (const QModelIndex &index)
 Starts editing the item corresponding to the given index if it is editable.
 
void clearSelection ()
 Deselects all selected items.
 
void setCurrentIndex (const QModelIndex &index)
 Sets the current item to be the item at index.
 
void scrollToTop ()
 
void scrollToBottom ()
 
void update (const QModelIndex &index)
 
- Protected Types inherited from QAbstractItemView
enum  CursorAction {
  MoveUp , MoveDown , MoveLeft , MoveRight ,
  MoveHome , MoveEnd , MovePageUp , MovePageDown ,
  MoveNext , MovePrevious
}
 This enum describes the different ways to navigate between items,. More...
 
enum  State {
  NoState , DraggingState , DragSelectingState , EditingState ,
  ExpandingState , CollapsingState , AnimatingState
}
 Describes the different states the view can be in. More...
 
- Protected Slots inherited from QAbstractItemView
virtual void updateEditorData ()
 
virtual void updateEditorGeometries ()
 
virtual void verticalScrollbarAction (int action)
 
virtual void horizontalScrollbarAction (int action)
 
virtual void verticalScrollbarValueChanged (int value)
 
virtual void horizontalScrollbarValueChanged (int value)
 
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 Closes the given editor, and releases it.
 
virtual void commitData (QWidget *editor)
 Commit the data in the editor to the model.
 
virtual void editorDestroyed (QObject *editor)
 This function is called when the given editor has been destroyed.
 

Detailed Description

The QListView class provides a list or icon view onto a model.

\inmodule QtWidgets

A QListView presents items stored in a model, either as a simple non-hierarchical list, or as a collection of icons. This class is used to provide lists and icon views that were previously provided by the QListBox and QIconView classes, but using the more flexible approach provided by Qt's model/view architecture.

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

This view does not display horizontal or vertical headers; to display a list of items with a horizontal header, use QTreeView instead.

QListView implements the interfaces defined by the QAbstractItemView class to allow it to display data provided by models derived from the QAbstractItemModel class.

Items in a list view can be displayed using one of two view modes: In \l ListMode, the items are displayed in the form of a simple list; in \l IconMode, the list view takes the form of an {icon view} in which the items are displayed with icons like files in a file manager. By default, the list view is in \l ListMode. To change the view mode, use the setViewMode() function, and to determine the current view mode, use viewMode().

Items in these views are laid out in the direction specified by the flow() of the list view. The items may be fixed in place, or allowed to move, depending on the view's movement() state.

If the items in the model cannot be completely laid out in the direction of flow, they can be wrapped at the boundary of the view widget; this depends on isWrapping(). This property is useful when the items are being represented by an icon view.

The resizeMode() and layoutMode() govern how and when the items are laid out. Items are spaced according to their spacing(), and can exist within a notional grid of size specified by gridSize(). The items can be rendered as large or small icons depending on their iconSize().

Definition at line 16 of file qlistview.h.

Member Enumeration Documentation

◆ Flow

\value LeftToRight The items are laid out in the view from the left to the right.

\value TopToBottom The items are laid out in the view from the top to the bottom.

Enumerator
LeftToRight 
TopToBottom 

Definition at line 37 of file qlistview.h.

◆ LayoutMode

\value SinglePass The items are laid out all at once.

\value Batched The items are laid out in batches of \l batchSize items.

See also
batchSize
Enumerator
SinglePass 
Batched 

Definition at line 41 of file qlistview.h.

◆ Movement

\value Static The items cannot be moved by the user.

\value Free The items can be moved freely by the user. \value Snap The items snap to the specified grid when moved; see setGridSize().

Enumerator
Static 
Free 
Snap 

Definition at line 35 of file qlistview.h.

◆ ResizeMode

\value Fixed The items will only be laid out the first time the view is shown.

\value Adjust The items will be laid out every time the view is resized.

Enumerator
Fixed 
Adjust 

Definition at line 39 of file qlistview.h.

◆ ViewMode

\value ListMode The items are laid out using TopToBottom flow, with Small size and Static movement \value IconMode The items are laid out using LeftToRight flow, with Large size and Free movement

Enumerator
ListMode 
IconMode 

Definition at line 43 of file qlistview.h.

Constructor & Destructor Documentation

◆ QListView() [1/2]

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

Creates a new QListView with the given parent to view a model.

Use setModel() to set the model.

Definition at line 145 of file qlistview.cpp.

References d, ListMode, setAttribute(), QAbstractItemView::setSelectionMode(), setViewMode(), QAbstractItemView::SingleSelection, and Qt::WA_MacShowFocusRect.

+ Here is the call graph for this function:

◆ ~QListView()

QListView::~QListView ( )

Destroys the view.

Definition at line 171 of file qlistview.cpp.

◆ QListView() [2/2]

QListView::QListView ( QListViewPrivate & dd,
QWidget * parent = nullptr )
protected

Definition at line 158 of file qlistview.cpp.

References d, ListMode, setAttribute(), QAbstractItemView::setSelectionMode(), setViewMode(), QAbstractItemView::SingleSelection, and Qt::WA_MacShowFocusRect.

+ Here is the call graph for this function:

Member Function Documentation

◆ batchSize()

int QListView::batchSize ( ) const

Definition at line 372 of file qlistview.cpp.

References d.

◆ clearPropertyFlags()

void QListView::clearPropertyFlags ( )

Clears the QListView-specific property flags.

See \l{viewMode}.

Properties inherited from QAbstractItemView are not covered by the property flags. Specifically, \l{QAbstractItemView::dragEnabled} {dragEnabled} and \l{QAbstractItemView::acceptDrops} {acceptsDrops} are computed by QListView when calling setMovement() or setViewMode().

Definition at line 488 of file qlistview.cpp.

References d.

◆ contentsSize()

QSize QListView::contentsSize ( ) const
protected

Definition at line 692 of file qlistview.cpp.

References d.

Referenced by QComboBoxListView::resizeEvent(), setSelection(), and updateGeometries().

+ Here is the caller graph for this function:

◆ currentChanged()

void QListView::currentChanged ( const QModelIndex & current,
const QModelIndex & previous )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 3411 of file qlistview.cpp.

References QAbstractItemView::currentChanged(), and QModelIndex::isValid().

Referenced by QFontListView::currentChanged().

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

◆ dataChanged()

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

\reimp

Reimplemented from QAbstractItemView.

Definition at line 701 of file qlistview.cpp.

References QAbstractItemView::dataChanged().

+ Here is the call graph for this function:

◆ doItemsLayout()

void QListView::doItemsLayout ( )
overridevirtual

Layout the items according to the flow and wrapping properties.

Reimplemented from QAbstractItemView.

Definition at line 1544 of file qlistview.cpp.

References d, QAbstractItemView::doItemsLayout(), QAbstractItemView::ExpandingState, layoutMode, QAbstractItemView::setState(), SinglePass, and QAbstractItemView::state().

+ Here is the call graph for this function:

◆ event()

bool QListView::event ( QEvent * e)
overrideprotected

\reimp

Definition at line 1753 of file qlistview.cpp.

References QAbstractItemView::event().

Referenced by QSidebar::event(), and QListWidget::event().

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

◆ flow()

QListView::Flow QListView::flow ( ) const

Definition at line 239 of file qlistview.cpp.

References d.

◆ gridSize()

QSize QListView::gridSize ( ) const

Definition at line 401 of file qlistview.cpp.

References d.

◆ horizontalOffset()

int QListView::horizontalOffset ( ) const
overrideprotectedvirtual

\reimp

Implements QAbstractItemView.

Definition at line 1116 of file qlistview.cpp.

Referenced by indexAt(), mouseMoveEvent(), paintEvent(), and setSelection().

+ Here is the caller graph for this function:

◆ indexAt()

QModelIndex QListView::indexAt ( const QPoint & p) const
overridevirtual

\reimp

Implements QAbstractItemView.

Definition at line 1101 of file qlistview.cpp.

References contains(), d, horizontalOffset(), rect, verticalOffset(), and visualRect().

Referenced by QListWidget::itemAt().

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

◆ indexesMoved

void QListView::indexesMoved ( const QModelIndexList & indexes)
signal
Since
4.2

This signal is emitted when the specified indexes are moved in the view.

◆ initViewItemOption()

void QListView::initViewItemOption ( QStyleOptionViewItem * option) const
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 963 of file qlistview.cpp.

References Qt::AlignCenter, d, IconMode, QAbstractItemView::initViewItemOption(), ListMode, QStyle::PM_IconViewIconSize, and QStyle::PM_ListViewIconSize.

Referenced by QCommonListViewBase::initViewItemOption(), QComboBoxListView::initViewItemOption(), paintEvent(), updateGeometries(), and viewportSizeHint().

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

◆ isIndexHidden()

bool QListView::isIndexHidden ( const QModelIndex & index) const
overrideprotectedvirtual

\reimp

Implements QAbstractItemView.

Definition at line 1608 of file qlistview.cpp.

References d.

Referenced by selectedIndexes().

+ Here is the caller graph for this function:

◆ isRowHidden()

bool QListView::isRowHidden ( int row) const

Returns true if the row is hidden; otherwise returns false.

Definition at line 497 of file qlistview.cpp.

References d.

Referenced by QListWidgetItem::isHidden(), and QComboBox::showPopup().

+ Here is the caller graph for this function:

◆ isSelectionRectVisible()

bool QListView::isSelectionRectVisible ( ) const

Definition at line 1718 of file qlistview.cpp.

References d.

◆ isWrapping()

bool QListView::isWrapping ( ) const

Definition at line 268 of file qlistview.cpp.

References d.

◆ itemAlignment()

Qt::Alignment QListView::itemAlignment ( ) const

Definition at line 1744 of file qlistview.cpp.

References d.

◆ layoutMode()

QListView::LayoutMode QListView::layoutMode ( ) const

Definition at line 318 of file qlistview.cpp.

References d.

◆ modelColumn()

int QListView::modelColumn ( ) const

Definition at line 1638 of file qlistview.cpp.

References d.

◆ mouseMoveEvent()

void QListView::mouseMoveEvent ( QMouseEvent * e)
overrideprotected

\reimp

Definition at line 746 of file qlistview.cpp.

References QRect::adjusted(), d, QAbstractItemView::DragSelectingState, horizontalOffset(), isVisible(), QAbstractItemView::mouseMoveEvent(), QAbstractItemView::NoSelection, QStyle::PM_DefaultFrameWidth, QSinglePointEvent::position(), rect, QAbstractItemView::SingleSelection, QAbstractItemView::state(), QPointF::toPoint(), QRect::united(), and verticalOffset().

+ Here is the call graph for this function:

◆ mouseReleaseEvent()

void QListView::mouseReleaseEvent ( QMouseEvent * e)
overrideprotected

\reimp

Definition at line 769 of file qlistview.cpp.

References QRect::adjusted(), d, QAbstractItemView::mouseReleaseEvent(), and QStyle::PM_DefaultFrameWidth.

+ Here is the call graph for this function:

◆ moveCursor()

QModelIndex QListView::moveCursor ( CursorAction cursorAction,
Qt::KeyboardModifiers modifiers )
overrideprotectedvirtual

\reimp

Implements QAbstractItemView.

Definition at line 1132 of file qlistview.cpp.

References QRect::bottom(), contents, QAbstractItemView::currentIndex(), d, QRect::height(), QModelIndex::isValid(), LeftToRight, QModelIndex::model(), moveCursor(), QAbstractItemView::MoveDown, QAbstractItemView::MoveEnd, QAbstractItemView::MoveHome, QAbstractItemView::MoveLeft, QAbstractItemView::MoveNext, QAbstractItemView::MovePageDown, QAbstractItemView::MovePageUp, QAbstractItemView::MovePrevious, QAbstractItemView::MoveRight, QAbstractItemView::MoveUp, Q_UNUSED, rect, rectForIndex(), QModelIndex::row(), QRect::setSize(), QRect::top(), and TopToBottom.

Referenced by moveCursor().

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

◆ movement()

QListView::Movement QListView::movement ( ) const

Definition at line 208 of file qlistview.cpp.

References d.

◆ paintEvent()

◆ rectForIndex()

QRect QListView::rectForIndex ( const QModelIndex & index) const
protected

Returns the rectangle of the item at position index in the model.

The rectangle is in contents coordinates.

See also
visualRect()

Definition at line 1313 of file qlistview.cpp.

Referenced by moveCursor(), and visualRect().

+ Here is the caller graph for this function:

◆ reset()

void QListView::reset ( )
overridevirtual

Reimplemented from QAbstractItemView.

Definition at line 643 of file qlistview.cpp.

References d, and QAbstractItemView::reset().

+ Here is the call graph for this function:

◆ resizeContents()

void QListView::resizeContents ( int width,
int height )
protected

Resize the internal contents to width and height and set the scroll bar ranges accordingly.

Definition at line 683 of file qlistview.cpp.

References d.

Referenced by QComboBoxListView::resizeEvent().

+ Here is the caller graph for this function:

◆ resizeEvent()

void QListView::resizeEvent ( QResizeEvent * e)
overrideprotected

\reimp

Definition at line 830 of file qlistview.cpp.

References Adjust, d, QSize::height(), QSize::isNull(), LeftToRight, ListMode, QAbstractItemView::NoState, QResizeEvent::oldSize(), QAbstractItemView::resizeEvent(), QResizeEvent::size(), QAbstractItemView::state(), TopToBottom, and QSize::width().

Referenced by QComboBoxListView::resizeEvent().

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

◆ resizeMode()

QListView::ResizeMode QListView::resizeMode ( ) const

Definition at line 293 of file qlistview.cpp.

References d.

◆ rowsAboutToBeRemoved()

void QListView::rowsAboutToBeRemoved ( const QModelIndex & parent,
int start,
int end )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 723 of file qlistview.cpp.

References QSet< T >::begin(), QSet< T >::clear(), d, QSet< T >::end(), QSet< T >::erase(), it, and QAbstractItemView::rowsAboutToBeRemoved().

+ Here is the call graph for this function:

◆ rowsInserted()

void QListView::rowsInserted ( const QModelIndex & parent,
int start,
int end )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 711 of file qlistview.cpp.

References d, and QAbstractItemView::rowsInserted().

+ Here is the call graph for this function:

◆ scrollContentsBy()

void QListView::scrollContentsBy ( int dx,
int dy )
overrideprotected

\reimp

Scroll the view contents by dx and dy.

Definition at line 670 of file qlistview.cpp.

References d, and QAbstractItemView::DragSelectingState.

◆ scrollTo()

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

\reimp

Implements QAbstractItemView.

Definition at line 531 of file qlistview.cpp.

References d, QAbstractItemView::EnsureVisible, hint(), LeftToRight, rect, TopToBottom, and visualRect().

Referenced by QListWidget::scrollToItem().

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

◆ selectedIndexes()

QModelIndexList QListView::selectedIndexes ( ) const
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 1525 of file qlistview.cpp.

References d, and isIndexHidden().

+ Here is the call graph for this function:

◆ selectionChanged()

void QListView::selectionChanged ( const QItemSelection & selected,
const QItemSelection & deselected )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 3429 of file qlistview.cpp.

References QItemSelection::indexes(), and QAbstractItemView::selectionChanged().

+ Here is the call graph for this function:

◆ setBatchSize()

void QListView::setBatchSize ( int batchSize)

Definition at line 362 of file qlistview.cpp.

References batchSize, d, Q_UNLIKELY, and qWarning.

◆ setFlow()

void QListView::setFlow ( Flow flow)

Definition at line 231 of file qlistview.cpp.

References d, flow, and QListViewPrivate::Flow.

◆ setGridSize()

void QListView::setGridSize ( const QSize & size)

Definition at line 393 of file qlistview.cpp.

References d, and QListViewPrivate::GridSize.

◆ setItemAlignment()

void QListView::setItemAlignment ( Qt::Alignment alignment)

Definition at line 1734 of file qlistview.cpp.

References alignment, d, flow, isWrapping, ListMode, TopToBottom, and viewMode.

◆ setLayoutMode()

void QListView::setLayoutMode ( LayoutMode mode)

Definition at line 312 of file qlistview.cpp.

References d.

◆ setModelColumn()

void QListView::setModelColumn ( int column)

Definition at line 1623 of file qlistview.cpp.

References d.

Referenced by QCompleter::popup(), QCompleter::setCompletionColumn(), and QCompleter::setPopup().

+ Here is the caller graph for this function:

◆ setMovement()

void QListView::setMovement ( Movement movement)

Definition at line 194 of file qlistview.cpp.

References d, movement, QListViewPrivate::Movement, and Static.

◆ setPositionForIndex()

void QListView::setPositionForIndex ( const QPoint & position,
const QModelIndex & index )
protected
Since
4.1

Sets the contents position of the item at index in the model to the given position. If the list view's movement mode is Static or its view mode is ListView, this function will have no effect.

Definition at line 1326 of file qlistview.cpp.

References d, position(), and Static.

+ Here is the call graph for this function:

◆ setResizeMode()

void QListView::setResizeMode ( ResizeMode mode)

Definition at line 286 of file qlistview.cpp.

References d, and QListViewPrivate::ResizeMode.

Referenced by QFileDialogListView::setFileDialogPrivate().

+ Here is the caller graph for this function:

◆ setRootIndex()

void QListView::setRootIndex ( const QModelIndex & index)
overridevirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 654 of file qlistview.cpp.

References d, qMax(), qMin(), and QAbstractItemView::setRootIndex().

+ Here is the call graph for this function:

◆ setRowHidden()

void QListView::setRowHidden ( int row,
bool hide )

If hide is true, the given row will be hidden; otherwise the row will be shown.

Definition at line 507 of file qlistview.cpp.

References d, and hide().

Referenced by QListWidgetItem::setHidden().

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

◆ setSelection()

void QListView::setSelection ( const QRect & rect,
QItemSelectionModel::SelectionFlags command )
overrideprotectedvirtual

\reimp

Implements QAbstractItemView.

Definition at line 1342 of file qlistview.cpp.

References ch, contentsSize(), d, QAbstractItemView::DragSelectingState, gridSize, QSize::height(), horizontalOffset(), QModelIndex::isValid(), LeftToRight, QItemSelection::merge(), qMax(), qMin(), qSwap(), rect, QItemSelectionModel::Select, QItemSelection::select(), selection, QRect::setBottom(), QRect::setLeft(), QRect::setRight(), QRect::setTop(), QAbstractItemView::state(), and verticalOffset().

+ Here is the call graph for this function:

◆ setSelectionRectVisible()

void QListView::setSelectionRectVisible ( bool show)

Definition at line 1711 of file qlistview.cpp.

References d, QListViewPrivate::SelectionRectVisible, and show().

+ Here is the call graph for this function:

◆ setSpacing()

void QListView::setSpacing ( int space)

Definition at line 338 of file qlistview.cpp.

References d, and QListViewPrivate::Spacing.

◆ setUniformItemSizes()

void QListView::setUniformItemSizes ( bool enable)

Definition at line 1655 of file qlistview.cpp.

References d.

Referenced by QSidebar::setModelAndUrls().

+ Here is the caller graph for this function:

◆ setViewMode()

void QListView::setViewMode ( ViewMode mode)

Definition at line 422 of file qlistview.cpp.

References d, Fixed, QListViewPrivate::Flow, Free, QListViewPrivate::GridSize, LeftToRight, ListMode, QListViewPrivate::Movement, QAbstractItemView::QListModeViewBase, QListViewPrivate::ResizeMode, QListViewPrivate::SelectionRectVisible, QListViewPrivate::Spacing, Static, TopToBottom, and QListViewPrivate::Wrap.

Referenced by QListView(), and QListView().

+ Here is the caller graph for this function:

◆ setWordWrap()

void QListView::setWordWrap ( bool on)

Definition at line 1681 of file qlistview.cpp.

References d.

◆ setWrapping()

void QListView::setWrapping ( bool enable)

Definition at line 260 of file qlistview.cpp.

References d, and QListViewPrivate::Wrap.

Referenced by QFileDialogListView::setFileDialogPrivate().

+ Here is the caller graph for this function:

◆ spacing()

int QListView::spacing ( ) const

Definition at line 346 of file qlistview.cpp.

References d.

◆ timerEvent()

void QListView::timerEvent ( QTimerEvent * e)
overrideprotected

\reimp

Definition at line 814 of file qlistview.cpp.

References d, QAbstractItemView::timerEvent(), QTimerEvent::timerId(), and updateGeometries().

+ Here is the call graph for this function:

◆ uniformItemSizes()

bool QListView::uniformItemSizes ( ) const

Definition at line 1661 of file qlistview.cpp.

References d.

◆ updateGeometries()

void QListView::updateGeometries ( )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 1570 of file qlistview.cpp.

References contentsSize(), d, initViewItemOption(), QModelIndex::model(), Qt::ScrollBarAlwaysOff, Static, TopToBottom, QAbstractItemView::updateGeometries(), and viewport().

Referenced by timerEvent().

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

◆ verticalOffset()

int QListView::verticalOffset ( ) const
overrideprotectedvirtual

\reimp

Implements QAbstractItemView.

Definition at line 1124 of file qlistview.cpp.

Referenced by indexAt(), mouseMoveEvent(), paintEvent(), and setSelection().

+ Here is the caller graph for this function:

◆ viewMode()

QListView::ViewMode QListView::viewMode ( ) const

Definition at line 473 of file qlistview.cpp.

References d.

◆ viewportSizeHint()

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

Definition at line 3472 of file qlistview.cpp.

References d, QSize::height(), initViewItemOption(), QSize::isValid(), isWrapping, QModelIndex::model(), property, qMax(), qMin(), QSize::setHeight(), uniformItemSizes, QAbstractItemView::viewportSizeHint(), and QSize::width().

+ Here is the call graph for this function:

◆ visualRect()

QRect QListView::visualRect ( const QModelIndex & index) const
overridevirtual

\reimp

Implements QAbstractItemView.

Definition at line 522 of file qlistview.cpp.

References d, and rectForIndex().

Referenced by indexAt(), paintEvent(), scrollTo(), QListWidget::visualItemRect(), and visualRegionForSelection().

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

◆ visualRegionForSelection()

QRegion QListView::visualRegionForSelection ( const QItemSelection & selection) const
overrideprotectedvirtual

\reimp

Since 4.7, the returned region only contains rectangles intersecting (or included in) the viewport.

Implements QAbstractItemView.

Definition at line 1484 of file qlistview.cpp.

References d, IconMode, QRect::intersects(), QModelIndex::model(), QModelIndex::parent(), rect, QModelIndex::row(), selection, and visualRect().

+ Here is the call graph for this function:

◆ wordWrap()

bool QListView::wordWrap ( ) const

Definition at line 1690 of file qlistview.cpp.

References d.

Friends And Related Symbol Documentation

◆ QCommonListViewBase

friend class QCommonListViewBase
friend

Definition at line 161 of file qlistview.h.

Property Documentation

◆ batchSize

QListView::batchSize
readwrite

the number of items laid out in each batch if \l layoutMode is set to \l Batched.

The default value is 100.

Since
4.2

Definition at line 29 of file qlistview.h.

Referenced by setBatchSize().

◆ flow

QListView::flow
readwrite

which direction the items layout should flow.

If this property is \l LeftToRight, the items will be laid out left to right. If the \l isWrapping property is true, the layout will wrap when it reaches the right side of the visible area. If this property is \l TopToBottom, the items will be laid out from the top of the visible area, wrapping when it reaches the bottom.

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

By default, this property is set to \l TopToBottom.

See also
viewMode

Definition at line 20 of file qlistview.h.

Referenced by paintEvent(), setFlow(), and setItemAlignment().

◆ gridSize

QListView::gridSize
readwrite

the size of the layout grid

This property is the size of the grid in which the items are laid out. The default is an empty size which means that there is no grid and the layout is not done in a grid. Setting this property to a non-empty size switches on the grid layout. (When a grid layout is in force the \l spacing property is ignored.)

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

See also
viewMode

Definition at line 25 of file qlistview.h.

Referenced by setSelection().

◆ isWrapping

QListView::isWrapping
readwrite

whether the items layout should wrap.

This property holds whether the layout should wrap when there is no more space in the visible area. The point at which the layout wraps depends on the \l flow property.

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

By default, this property is false.

See also
viewMode

Definition at line 21 of file qlistview.h.

Referenced by setItemAlignment(), and viewportSizeHint().

◆ itemAlignment

QListView::itemAlignment
readwrite

the alignment of each item in its cell

Since
5.12

This is only supported in ListMode with TopToBottom flow and with wrapping enabled. The default alignment is 0, which means that an item fills its cell entirely.

Definition at line 32 of file qlistview.h.

◆ layoutMode

QListView::layoutMode
readwrite

determines whether the layout of items should happen immediately or be delayed.

This property holds the layout mode for the items. When the mode is \l SinglePass (the default), the items are laid out all in one go. When the mode is \l Batched, the items are laid out in batches of \l batchSize items, while processing events. This makes it possible to instantly view and interact with the visible items while the rest are being laid out.

See also
viewMode

Definition at line 23 of file qlistview.h.

Referenced by doItemsLayout().

◆ modelColumn

QListView::modelColumn
readwrite

the column in the model that is visible

By default, this property contains 0, indicating that the first column in the model will be shown.

Definition at line 27 of file qlistview.h.

◆ movement

QListView::movement
readwrite

whether the items can be moved freely, are snapped to a grid, or cannot be moved at all.

This property determines how the user can move the items in the view. \l Static means that the items can't be moved by the user. \l Free means that the user can drag and drop the items to any position in the view. \l Snap means that the user can drag and drop the items, but only to the positions in a notional grid signified by the gridSize property.

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

By default, this property is set to \l Static.

See also
gridSize, resizeMode, viewMode

Definition at line 19 of file qlistview.h.

Referenced by setMovement().

◆ resizeMode

QListView::resizeMode
readwrite

whether the items are laid out again when the view is resized.

If this property is \l Adjust, the items will be laid out again when the view is resized. If the value is \l Fixed, the items will not be laid out when the view is resized.

By default, this property is set to \l Fixed.

See also
movement, gridSize, viewMode

Definition at line 22 of file qlistview.h.

◆ selectionRectVisible

QListView::selectionRectVisible
readwrite

if the selection rectangle should be visible

Since
4.3

If this property is true then the selection rectangle is visible; otherwise it will be hidden.

Note
The selection rectangle will only be visible if the selection mode is in a mode where more than one item can be selected; i.e., it will not draw a selection rectangle if the selection mode is QAbstractItemView::SingleSelection.

By default, this property is false.

Definition at line 31 of file qlistview.h.

◆ spacing

QListView::spacing
readwrite

the space around the items in the layout

This property is the size of the empty space that is padded around an item in the layout.

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

By default, this property contains a value of 0.

See also
viewMode

Definition at line 24 of file qlistview.h.

◆ uniformItemSizes

QListView::uniformItemSizes
readwrite

whether all items in the listview have the same size

Since
4.1

This property should only be set to true if it is guaranteed that all items in the view have the same size. This enables the view to do some optimizations for performance purposes.

By default, this property is false.

Definition at line 28 of file qlistview.h.

Referenced by viewportSizeHint().

◆ viewMode

QListView::viewMode
readwrite

the view mode of the QListView.

This property will change the other unset properties to conform with the set view mode. QListView-specific properties that have already been set will not be changed, unless clearPropertyFlags() has been called.

Setting the view mode will enable or disable drag and drop based on the selected movement. For ListMode, the default movement is \l Static (drag and drop disabled); for IconMode, the default movement is \l Free (drag and drop enabled).

See also
isWrapping, spacing, gridSize, flow, movement, resizeMode

Definition at line 26 of file qlistview.h.

Referenced by QWindows11Style::drawControl(), and setItemAlignment().

◆ wordWrap

QListView::wordWrap
readwrite

the item text word-wrapping policy

Since
4.2

If this property is true then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is false by default.

Please note that even if wrapping is enabled, the cell will not be expanded to make room for the text. It will print ellipsis for text that cannot be shown, according to the view's \l{QAbstractItemView::}{textElideMode}.

Definition at line 30 of file qlistview.h.


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