summaryrefslogtreecommitdiffstats
path: root/src/widgets/doc/snippets/code/doc_src_model-view-programming.cpp
blob: f63578f66efd4e0d7e9e9ca297908f32fc5f0b5c (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

//! [0]
QAbstractItemModel *model = index.model();
//! [0]


//! [1]
QModelIndex index = model->index(row, column, ...);
//! [1]


//! [2]
QModelIndex indexA = model->index(0, 0, QModelIndex());
QModelIndex indexB = model->index(1, 1, QModelIndex());
QModelIndex indexC = model->index(2, 1, QModelIndex());
//! [2]


//! [3]
QModelIndex index = model->index(row, column, parent);
//! [3]


//! [4]
QModelIndex indexA = model->index(0, 0, QModelIndex());
QModelIndex indexC = model->index(2, 1, QModelIndex());
//! [4]


//! [5]
QModelIndex indexB = model->index(1, 0, indexA);
//! [5]


//! [6]
QVariant value = model->data(index, role);
//! [6]