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
src_corelib_kernel_qabstractitemmodel.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5beginInsertRows(parent, 2, 4);
7
8
10beginInsertRows(parent, 4, 5);
12
13
15beginRemoveRows(parent, 2, 3);
17
18
20beginInsertColumns(parent, 4, 6);
22
23
25beginInsertColumns(parent, 6, 8);
27
28
30beginRemoveColumns(parent, 4, 6);
32
33
35beginMoveRows(sourceParent, 2, 4, destinationParent, 2);
37
38
40beginMoveRows(sourceParent, 2, 4, destinationParent, 6);
42
43
45beginMoveRows(parent, 2, 2, parent, 0);
47
48
50beginMoveRows(parent, 2, 2, parent, 4);
52
53
56{
58public:
63
64 ...
65
66 QVariant data(const QModelIndex &index, int role) override
67 {
68 if (role != Qt::BackgroundRole)
70
71 if (m_customData.contains(index.row()))
72 return m_customData.value(index.row());
74 }
75
76private slots:
77 void resetInternalData()
78 {
79 m_customData.clear();
80 }
81
82private:
83 QHash<int, QVariant> m_customData;
84};
86
91// etc.
93
100
101// Usually, this is not necessary: A QModelRoleDataSpan
102// will be built automatically for you when passing an array-like
103// container to multiData().
105
107
108// Use roleData[0].data(), roleData[1].data(), etc.
110
112void MyModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const
113{
114 for (QModelRoleData &roleData : roleDataSpan) {
115 int role = roleData.role();
116
117 // ... obtain the data for index and role ...
118
119 roleData.setData(result);
120 }
121}
123
126{
129 return roleData.data();
130}
QVariant data(const QModelIndex &index, int role) override
QVariant data(const QModelIndex &item, int role) const override
[15]
virtual void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
Definition qhash.h:1007
T value(const Key &key) const noexcept
Definition qhash.h:1054
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
Definition qhash.h:951
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
The QSortFilterProxyModel class provides support for sorting and filtering data passed between anothe...
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
\reimp
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
Returns the value for the specified item and role.
\inmodule QtCore
Definition qvariant.h:65
@ DecorationRole
@ BackgroundRole
@ CheckStateRole
@ DisplayRole
GLuint index
[2]
GLenum GLenum GLsizei void GLsizei void void * span
GLuint64EXT * result
[6]
#define Q_OBJECT
#define slots
QSqlQueryModel * model
[16]
beginInsertRows(parent, 2, 4)
[0]
QModelRoleDataSpan span(roleData)
beginMoveRows(sourceParent, 2, 4, destinationParent, 2)
[5]
std::array< QModelRoleData, 3 > roleData
[13]
beginInsertColumns(parent, 4, 6)
[2]
beginRemoveColumns(parent, 4, 6)
[4]
beginRemoveRows(parent, 2, 3)
[1]