QtBase
v6.3.1
|
The QListView class provides a list or icon view onto a model. More...
#include <qlistview.h>
Public Types | |
enum | Movement { Static , Free , Snap } |
enum | Flow { LeftToRight , TopToBottom } |
enum | ResizeMode { Fixed , Adjust } |
enum | LayoutMode { SinglePass , Batched } |
enum | ViewMode { ListMode , IconMode } |
Public Types inherited from QAbstractItemView | |
enum | SelectionMode { NoSelection , SingleSelection , MultiSelection , ExtendedSelection , ContiguousSelection } |
enum | SelectionBehavior { SelectItems , SelectRows , SelectColumns } |
enum | ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter } |
enum | EditTrigger { NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 , EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31 } |
enum | ScrollMode { ScrollPerItem , ScrollPerPixel } |
Signals | |
void | indexesMoved (const QModelIndexList &indexes) |
Signals inherited from QAbstractItemView | |
void | pressed (const QModelIndex &index) |
void | clicked (const QModelIndex &index) |
void | doubleClicked (const QModelIndex &index) |
void | activated (const QModelIndex &index) |
void | entered (const QModelIndex &index) |
void | viewportEntered () |
void | iconSizeChanged (const QSize &size) |
Properties | |
Movement | movement |
whether the items can be moved freely, are snapped to a grid, or cannot be moved at all. More... | |
Flow | flow |
which direction the items layout should flow. More... | |
bool | isWrapping |
whether the items layout should wrap. More... | |
ResizeMode | resizeMode |
whether the items are laid out again when the view is resized. More... | |
LayoutMode | layoutMode |
determines whether the layout of items should happen immediately or be delayed. More... | |
int | spacing |
the space around the items in the layout More... | |
QSize | gridSize |
the size of the layout grid More... | |
ViewMode | viewMode |
the view mode of the QListView. More... | |
int | modelColumn |
the column in the model that is visible More... | |
bool | uniformItemSizes |
whether all items in the listview have the same size More... | |
int | batchSize |
the number of items laid out in each batch if \l layoutMode is set to \l Batched More... | |
bool | wordWrap |
the item text word-wrapping policy More... | |
bool | selectionRectVisible |
if the selection rectangle should be visible More... | |
Qt::Alignment | itemAlignment |
the alignment of each item in its cell More... | |
Properties inherited from QAbstractItemView | |
bool | autoScroll |
whether autoscrolling in drag move events is enabled More... | |
int | autoScrollMargin |
the size of the area when auto scrolling is triggered More... | |
EditTriggers | editTriggers |
which actions will initiate item editing More... | |
bool | tabKeyNavigation |
whether item navigation with tab and backtab is enabled. More... | |
bool | alternatingRowColors |
whether to draw the background using alternating colors More... | |
SelectionMode | selectionMode |
which selection mode the view operates in More... | |
SelectionBehavior | selectionBehavior |
which selection behavior the view uses More... | |
QSize | iconSize |
the size of items' icons More... | |
Qt::TextElideMode | textElideMode |
the position of the "..." in elided text. More... | |
ScrollMode | verticalScrollMode |
how the view scrolls its contents in the vertical direction More... | |
ScrollMode | horizontalScrollMode |
how the view scrolls its contents in the horizontal direction More... | |
Friends | |
class | QCommonListViewBase |
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 52 of file qlistview.h.
enum QListView::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 73 of file qlistview.h.
\value SinglePass The items are laid out all at once. \value Batched The items are laid out in batches of \l batchSize items.
Enumerator | |
---|---|
SinglePass | |
Batched |
Definition at line 77 of file qlistview.h.
enum QListView::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 71 of file qlistview.h.
\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 75 of file qlistview.h.
enum QListView::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 79 of file qlistview.h.
Creates a new QListView with the given parent to view a model. Use setModel() to set the model.
Definition at line 181 of file qlistview.cpp.
QListView::~QListView | ( | ) |
Destroys the view.
Definition at line 207 of file qlistview.cpp.
|
protected |
int QListView::batchSize | ( | ) | const |
Definition at line 408 of file qlistview.cpp.
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 524 of file qlistview.cpp.
|
protected |
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 3429 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Reimplemented in QListWidgetDataChanged.
Definition at line 737 of file qlistview.cpp.
|
overridevirtual |
Reimplemented from QAbstractItemView.
Definition at line 1568 of file qlistview.cpp.
|
overrideprotected |
\reimp
Definition at line 1771 of file qlistview.cpp.
QListView::Flow QListView::flow | ( | ) | const |
Definition at line 275 of file qlistview.cpp.
QSize QListView::gridSize | ( | ) | const |
Definition at line 437 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Implements QAbstractItemView.
Definition at line 1146 of file qlistview.cpp.
|
overridevirtual |
\reimp
Implements QAbstractItemView.
Definition at line 1131 of file qlistview.cpp.
|
signal |
This signal is emitted when the specified indexes are moved in the view.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Reimplemented in QComboBoxListView.
Definition at line 993 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Implements QAbstractItemView.
Definition at line 1632 of file qlistview.cpp.
bool QListView::isRowHidden | ( | int | row | ) | const |
Returns true
if the row is hidden; otherwise returns false
.
Definition at line 533 of file qlistview.cpp.
bool QListView::isSelectionRectVisible | ( | ) | const |
Definition at line 1736 of file qlistview.cpp.
bool QListView::isWrapping | ( | ) | const |
Definition at line 304 of file qlistview.cpp.
Qt::Alignment QListView::itemAlignment | ( | ) | const |
Definition at line 1762 of file qlistview.cpp.
QListView::LayoutMode QListView::layoutMode | ( | ) | const |
Definition at line 354 of file qlistview.cpp.
int QListView::modelColumn | ( | ) | const |
Definition at line 1656 of file qlistview.cpp.
|
overrideprotected |
|
overrideprotected |
|
overrideprotectedvirtual |
\reimp
Implements QAbstractItemView.
Definition at line 1162 of file qlistview.cpp.
QListView::Movement QListView::movement | ( | ) | const |
Definition at line 244 of file qlistview.cpp.
|
overrideprotected |
\reimp
Definition at line 1020 of file qlistview.cpp.
|
protected |
Returns the rectangle of the item at position index in the model. The rectangle is in contents coordinates.
Definition at line 1337 of file qlistview.cpp.
|
overridevirtual |
Reset the internal state of the view.
Reimplemented from QAbstractItemView.
Definition at line 679 of file qlistview.cpp.
|
protected |
|
overrideprotected |
\reimp
Definition at line 861 of file qlistview.cpp.
QListView::ResizeMode QListView::resizeMode | ( | ) | const |
Definition at line 329 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 759 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 747 of file qlistview.cpp.
|
overrideprotected |
|
overridevirtual |
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 1549 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 3447 of file qlistview.cpp.
void QListView::setBatchSize | ( | int | batchSize | ) |
Definition at line 398 of file qlistview.cpp.
Definition at line 267 of file qlistview.cpp.
Definition at line 429 of file qlistview.cpp.
void QListView::setItemAlignment | ( | Qt::Alignment | alignment | ) |
Definition at line 1752 of file qlistview.cpp.
void QListView::setLayoutMode | ( | LayoutMode | mode | ) |
Definition at line 348 of file qlistview.cpp.
void QListView::setModelColumn | ( | int | column | ) |
|
protected |
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 1350 of file qlistview.cpp.
void QListView::setResizeMode | ( | ResizeMode | mode | ) |
|
overridevirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 690 of file qlistview.cpp.
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 543 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Implements QAbstractItemView.
Reimplemented in SetSelectionTestView.
Definition at line 1366 of file qlistview.cpp.
void QListView::setSelectionRectVisible | ( | bool | show | ) |
Definition at line 1729 of file qlistview.cpp.
void QListView::setSpacing | ( | int | space | ) |
void QListView::setUniformItemSizes | ( | bool | enable | ) |
void QListView::setWordWrap | ( | bool | on | ) |
Definition at line 1699 of file qlistview.cpp.
void QListView::setWrapping | ( | bool | enable | ) |
int QListView::spacing | ( | ) | const |
Definition at line 382 of file qlistview.cpp.
|
overrideprotected |
bool QListView::uniformItemSizes | ( | ) | const |
Definition at line 1679 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 1594 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Implements QAbstractItemView.
Definition at line 1154 of file qlistview.cpp.
QListView::ViewMode QListView::viewMode | ( | ) | const |
Definition at line 509 of file qlistview.cpp.
|
overrideprotected |
Definition at line 3490 of file qlistview.cpp.
|
overridevirtual |
\reimp
Implements QAbstractItemView.
Definition at line 558 of file qlistview.cpp.
|
overrideprotectedvirtual |
\reimp
Since 4.7, the returned region only contains rectangles intersecting (or included in) the viewport.
Implements QAbstractItemView.
Definition at line 1508 of file qlistview.cpp.
bool QListView::wordWrap | ( | ) | const |
Definition at line 1708 of file qlistview.cpp.
|
friend |
Definition at line 197 of file qlistview.h.
|
readwrite |
the number of items laid out in each batch if \l layoutMode is set to \l Batched
The default value is 100.
Definition at line 203 of file qlistview.h.
|
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.
Definition at line 203 of file qlistview.h.
|
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.
Definition at line 203 of file qlistview.h.
|
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
.
Definition at line 203 of file qlistview.h.
|
readwrite |
the alignment of each item in its cell
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 203 of file qlistview.h.
|
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.
Definition at line 203 of file qlistview.h.
|
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 203 of file qlistview.h.
|
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.
Definition at line 203 of file qlistview.h.
|
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.
Definition at line 203 of file qlistview.h.
|
readwrite |
if the selection rectangle should be visible
If this property is true
then the selection rectangle is visible; otherwise it will be hidden.
By default, this property is false
.
Definition at line 203 of file qlistview.h.
|
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.
Definition at line 203 of file qlistview.h.
|
readwrite |
whether all items in the listview have the same size
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 203 of file qlistview.h.
|
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).
Definition at line 203 of file qlistview.h.
|
readwrite |
the item text word-wrapping policy
If this property is true
then the item text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all. This property is false
by default.
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 203 of file qlistview.h.