blob: a4def6be545f806883a7e40bcce12419958070f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CPPTABLEMODEL_H
#define CPPTABLEMODEL_H
//![0]
#include <qqml.h>
#include <QAbstractTableModel>
class TableModel : public QAbstractTableModel
{
Q_OBJECT
QML_ELEMENT
QML_ADDED_IN_MINOR_VERSION(1)
public:
int rowCount(const QModelIndex & = QModelIndex()) const override
{
return 200;
}
int columnCount(const QModelIndex & = QModelIndex()) const override
{
return 200;
}
QVariant data(const QModelIndex &index, int role) const override
{
switch (role) {
case Qt::DisplayRole:
return QString("%1, %2").arg(index.column()).arg(index.row());
default:
break;
}
return QVariant();
}
QHash<int, QByteArray> roleNames() const override
{
return { {Qt::DisplayRole, "display"} };
}
};
//![0]
#endif // CPPTABLEMODEL_H
|