Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
doc_src_model-view-programming.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
4
#
include
<
QAbstractItemModel
>
5
#
include
<
QModelIndex
>
6
#
include
<
QVariant
>
7
8
void
examples
()
9
{
10
QModelIndex index;
11
12
//! [0]
13
const
QAbstractItemModel *model = index.model();
14
//! [0]
15
16
int
row, column;
17
18
{
19
//! [1]
20
QModelIndex index = model->index(row, column
/*...*/
);
21
//! [1]
22
}
23
24
{
25
//! [2]
26
QModelIndex indexA = model->index(0, 0, QModelIndex());
27
QModelIndex indexB = model->index(1, 1, QModelIndex());
28
QModelIndex indexC = model->index(2, 1, QModelIndex());
29
//! [2]
30
}
31
32
{
33
QModelIndex parent;
34
35
//! [3]
36
QModelIndex index = model->index(row, column, parent);
37
//! [3]
38
}
39
40
{
41
//! [4]
42
QModelIndex indexA = model->index(0, 0, QModelIndex());
43
QModelIndex indexC = model->index(2, 1, QModelIndex());
44
//! [4]
45
}
46
47
{
48
QModelIndex indexA;
49
50
//! [5]
51
QModelIndex indexB = model->index(1, 0, indexA);
52
//! [5]
53
}
54
55
{
56
QModelIndex index;
57
int
role = Qt::DisplayRole;
58
59
//! [6]
60
QVariant value = model->data(index, role);
61
//! [6]
62
}
63
}
examples
bool examples()
[3]
Definition
src_corelib_global_qglobal.cpp:56
qtbase
src
widgets
doc
snippets
code
doc_src_model-view-programming.cpp
Generated on
for Qt by
1.18.0