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
cpp-tablemodel.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#ifndef CPPTABLEMODEL_H
5#define CPPTABLEMODEL_H
6
8#include <qqml.h>
9#include <QAbstractTableModel>
10
12{
16
17public:
18 int rowCount(const QModelIndex & = QModelIndex()) const override
19 {
20 return 200;
21 }
22
23 int columnCount(const QModelIndex & = QModelIndex()) const override
24 {
25 return 200;
26 }
27
28 QVariant data(const QModelIndex &index, int role) const override
29 {
30 switch (role) {
31 case Qt::DisplayRole:
32 return QString("%1, %2").arg(index.column()).arg(index.row());
33 default:
34 break;
35 }
36
37 return QVariant();
38 }
39
40 QHash<int, QByteArray> roleNames() const override
41 {
42 return { {Qt::DisplayRole, "display"} };
43 }
44};
46
47#endif // CPPTABLEMODEL_H
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8870
\inmodule QtCore
Definition qvariant.h:65
[0]
Definition model.h:12
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of items in the row list as the number of rows in the model.
Definition model.cpp:38
int columnCount(const QModelIndex &=QModelIndex()) const override
Returns the number of columns for the children of the given parent.
QHash< int, QByteArray > roleNames() const override
QVariant data(const QModelIndex &index, int role) const override
Returns the data stored under the given role for the item referred to by the index.
@ DisplayRole
GLuint index
[2]
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QML_ELEMENT
#define Q_OBJECT