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.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QLISTVIEW_H
5#define QLISTVIEW_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qabstractitemview.h>
9
11
13
15
16class Q_WIDGETS_EXPORT QListView : public QAbstractItemView
17{
19 Q_PROPERTY(Movement movement READ movement WRITE setMovement)
20 Q_PROPERTY(Flow flow READ flow WRITE setFlow)
21 Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
22 Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
23 Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
24 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
25 Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
26 Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
27 Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
28 Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
29 Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
30 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
31 Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
32 Q_PROPERTY(Qt::Alignment itemAlignment READ itemAlignment WRITE setItemAlignment)
33
34public:
35 enum Movement { Static, Free, Snap };
36 Q_ENUM(Movement)
37 enum Flow { LeftToRight, TopToBottom };
38 Q_ENUM(Flow)
39 enum ResizeMode { Fixed, Adjust };
40 Q_ENUM(ResizeMode)
41 enum LayoutMode { SinglePass, Batched };
42 Q_ENUM(LayoutMode)
43 enum ViewMode { ListMode, IconMode };
44 Q_ENUM(ViewMode)
45
46 explicit QListView(QWidget *parent = nullptr);
47 ~QListView();
48
49 void setMovement(Movement movement);
50 Movement movement() const;
51
52 void setFlow(Flow flow);
53 Flow flow() const;
54
55 void setWrapping(bool enable);
56 bool isWrapping() const;
57
58 void setResizeMode(ResizeMode mode);
59 ResizeMode resizeMode() const;
60
61 void setLayoutMode(LayoutMode mode);
62 LayoutMode layoutMode() const;
63
64 void setSpacing(int space);
65 int spacing() const;
66
67 void setBatchSize(int batchSize);
68 int batchSize() const;
69
70 void setGridSize(const QSize &size);
71 QSize gridSize() const;
72
73 void setViewMode(ViewMode mode);
74 ViewMode viewMode() const;
75
76 void clearPropertyFlags();
77
78 bool isRowHidden(int row) const;
79 void setRowHidden(int row, bool hide);
80
81 void setModelColumn(int column);
82 int modelColumn() const;
83
84 void setUniformItemSizes(bool enable);
85 bool uniformItemSizes() const;
86
87 void setWordWrap(bool on);
88 bool wordWrap() const;
89
90 void setSelectionRectVisible(bool show);
91 bool isSelectionRectVisible() const;
92
93 void setItemAlignment(Qt::Alignment alignment);
94 Qt::Alignment itemAlignment() const;
95
96 QRect visualRect(const QModelIndex &index) const override;
97 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
98 QModelIndex indexAt(const QPoint &p) const override;
99
100 void doItemsLayout() override;
101 void reset() override;
102 void setRootIndex(const QModelIndex &index) override;
103
105 void indexesMoved(const QModelIndexList &indexes);
106
107protected:
108 QListView(QListViewPrivate &, QWidget *parent = nullptr);
109
110 bool event(QEvent *e) override;
111
112 void scrollContentsBy(int dx, int dy) override;
113
114 void resizeContents(int width, int height);
115 QSize contentsSize() const;
116
117 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
118 const QList<int> &roles = QList<int>()) override;
119 void rowsInserted(const QModelIndex &parent, int start, int end) override;
120 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
121
122 void mouseMoveEvent(QMouseEvent *e) override;
123 void mouseReleaseEvent(QMouseEvent *e) override;
124#if QT_CONFIG(wheelevent)
125 void wheelEvent(QWheelEvent *e) override;
126#endif
127
128 void timerEvent(QTimerEvent *e) override;
129 void resizeEvent(QResizeEvent *e) override;
130#if QT_CONFIG(draganddrop)
131 void dragMoveEvent(QDragMoveEvent *e) override;
132 void dragLeaveEvent(QDragLeaveEvent *e) override;
133 void dropEvent(QDropEvent *e) override;
134 void startDrag(Qt::DropActions supportedActions) override;
135#endif // QT_CONFIG(draganddrop)
136
137 void initViewItemOption(QStyleOptionViewItem *option) const override;
138 void paintEvent(QPaintEvent *e) override;
139
140 int horizontalOffset() const override;
141 int verticalOffset() const override;
142 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
143 QRect rectForIndex(const QModelIndex &index) const;
144 void setPositionForIndex(const QPoint &position, const QModelIndex &index);
145
146 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
147 QRegion visualRegionForSelection(const QItemSelection &selection) const override;
148 QModelIndexList selectedIndexes() const override;
149
150 void updateGeometries() override;
151
152 bool isIndexHidden(const QModelIndex &index) const override;
153
154 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
155 void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
156
157 QSize viewportSizeHint() const override;
158
159private:
160 int visualIndex(const QModelIndex &index) const;
162
163 Q_DECLARE_PRIVATE(QListView)
164 Q_DISABLE_COPY(QListView)
165};
166
168
169#endif // QLISTVIEW_H
The QAbstractItemView class provides the basic functionality for item view classes.
CursorAction
This enum describes the different ways to navigate between items,.
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:17
ViewMode
\value ListMode The items are laid out using TopToBottom flow, with Small size and Static movement \v...
Definition qlistview.h:43
ResizeMode
\value Fixed The items will only be laid out the first time the view is shown.
Definition qlistview.h:39
Movement
\value Static The items cannot be moved by the user.
Definition qlistview.h:35
Flow
\value LeftToRight The items are laid out in the view from the left to the right.
Definition qlistview.h:37
LayoutMode
\value SinglePass The items are laid out all at once.
Definition qlistview.h:41
void indexesMoved(const QModelIndexList &indexes)
\inmodule QtCore
\inmodule QtGui
Definition qevent.h:196
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
Definition qcoreevent.h:366
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
EGLImageKHR int int EGLuint64KHR * modifiers
qreal spacing
rect
[4]
uint alignment
Combined button and popup list for selecting options.
Definition qcompare.h:63
static jboolean setSelection(JNIEnv *, jobject, jint start, jint end)
static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
GLenum mode
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLint GLsizei width
GLboolean enable
GLuint start
GLenum GLenum GLsizei void GLsizei void * column
struct _cl_event * event
GLboolean reset
GLenum GLenum GLsizei void * row
GLfloat GLfloat p
[1]
GLuint GLenum option
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_REQUIRE_CONFIG(feature)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SIGNALS
view show()
[18] //! [19]
dialog setViewMode(QFileDialog::Detail)
[3]
edit hide()
QItemSelection * selection
[0]
spinBox setWrapping(true)
scroller scrollTo(QPointF(100, 100))