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
model.h
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
#
ifndef
MODEL_H
5
#
define
MODEL_H
6
7
#
include
<
QAbstractListModel
>
8
#
include
<
QObject
>
9
#
include
<
QStringList
>
10
11
//! [0]
12
class
StringListModel
:
public
QAbstractListModel
13
{
14
Q_OBJECT
15
16
public
:
17
StringListModel
(
const
QStringList
&
strings
,
QObject
*
parent
=
nullptr
)
18
:
QAbstractListModel
(
parent
),
stringList
(
strings
) {}
19
20
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
21
QVariant
data
(
const
QModelIndex &index,
int
role)
const
override
;
22
QVariant
headerData
(
int
section, Qt::Orientation orientation,
23
//! [0] //! [1]
24
int
role =
Qt
::
DisplayRole
)
const
override
;
25
//! [1]
26
27
//! [2]
28
Qt
::
ItemFlags
flags
(
const
QModelIndex &index)
const
override
;
29
bool
setData
(
const
QModelIndex &index,
const
QVariant &value,
30
//! [2] //! [3]
31
int
role =
Qt
::
EditRole
)
override
;
32
//! [3]
33
34
//! [4]
35
bool
insertRows
(
int
position,
int
rows,
const
QModelIndex &index = QModelIndex())
override
;
36
bool
removeRows
(
int
position,
int
rows,
const
QModelIndex &index = QModelIndex())
override
;
37
//! [4]
38
39
//! [5]
40
private
:
41
QStringList stringList;
42
};
43
//! [5]
44
45
#
endif
StringListModel
[0]
Definition
model.h:13
StringListModel::insertRows
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex()) override
[3]
Definition
model.cpp:143
StringListModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
[3]
Definition
model.cpp:124
StringListModel::data
QVariant data(const QModelIndex &index, int role) const override
[0]
Definition
model.cpp:62
StringListModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
[1]
Definition
model.cpp:103
StringListModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
[1]
Definition
model.cpp:84
StringListModel::removeRows
bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex()) override
[7]
Definition
model.cpp:162
main
int main(int argc, char *argv[])
[ctor_close]
Definition
src_corelib_animation_qpropertyanimation.cpp:100
qtbase
src
widgets
doc
snippets
stringlistmodel
model.h
Generated on
for Qt by
1.18.0