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
instancerepeater_p.h
Go to the documentation of this file.
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
6
//
7
// W A R N I N G
8
// -------------
9
//
10
// This file is not part of the Qt API. It exists purely as an
11
// implementation detail. This header file may change from version to
12
// version without notice, or even be removed.
13
//
14
// We mean it.
15
//
16
17
#
ifndef
INSTANCEREPEATER_P_H
18
#
define
INSTANCEREPEATER_P_H
19
20
#
include
<
QtQuick3DHelpers
/
qtquick3dhelpersexports
.
h
>
21
#
include
<
QtQuick3D
/
qquick3dinstancing
.
h
>
22
#
include
<
QtQuick3D
/
private
/
qquick3drepeater_p
.
h
>
23
#
include
<
QAbstractListModel
>
24
25
QT_BEGIN_NAMESPACE
26
27
class
Q_QUICK3DHELPERS_EXPORT
InstanceModel
:
public
QAbstractListModel
28
{
29
Q_OBJECT
30
Q_PROPERTY(QQuick3DInstancing *instancingTable READ instancing WRITE setInstancing NOTIFY instancingChanged)
31
QML_NAMED_ELEMENT(InstanceModel)
32
QML_ADDED_IN_VERSION(6, 4)
33
34
public
:
35
explicit
InstanceModel(QObject *parent =
nullptr
);
36
37
QVariant data(
const
QModelIndex &index,
int
role)
const
override;
38
int
rowCount(
const
QModelIndex &parent)
const
override;
39
40
QQuick3DInstancing *instancing()
const
{
return
m_instancing; }
41
void
setInstancing(QQuick3DInstancing *instancing);
42
43
const
QQuick3DInstancing::InstanceTableEntry *instanceData(
int
index)
const
;
44
45
enum
Roles {
46
PositionRole, RotationRole, ScaleRole, ColorRole, CustomDataRole
47
};
48
49
QHash<
int
, QByteArray> roleNames()
const
override {
50
return
{
51
{ ColorRole,
"modelColor"
},
52
{ PositionRole,
"modelPosition"
},
53
{ RotationRole,
"modelRotation"
},
54
{ ScaleRole,
"modelScale"
},
55
{ CustomDataRole,
"modelData"
}
56
};
57
}
58
59
private
slots:
60
void
reset();
61
62
signals:
63
void
instancingChanged();
64
65
private
:
66
void
ensureTable()
const
;
67
68
QQuick3DInstancing *m_instancing =
nullptr
;
69
70
QByteArray m_instanceData;
71
int
m_count = 0;
72
QMetaObject::Connection m_tableConnection;
73
};
74
75
class
Q_QUICK3DHELPERS_EXPORT
InstanceRepeater
:
public
QQuick3DRepeater
76
{
77
Q_OBJECT
78
Q_PROPERTY(QQuick3DInstancing *instancingTable READ instancing WRITE setInstancing NOTIFY instancingChanged)
79
QML_NAMED_ELEMENT(InstanceRepeater)
80
QML_ADDED_IN_VERSION(6, 4)
81
82
public
:
83
explicit
InstanceRepeater(QQuick3DNode *parent =
nullptr
);
84
QQuick3DInstancing *instancing()
const
;
85
void
setInstancing(QQuick3DInstancing *instancing);
86
signals:
87
void
instancingChanged();
88
protected
:
89
void
initDelegate(
int
index, QQuick3DNode *node) override;
90
private
:
91
InstanceModel *m_model =
nullptr
;
92
};
93
QT_END_NAMESPACE
94
#
endif
// INSTANCEREPEATER_P_H
InstanceModel
Definition
instancerepeater_p.h:28
InstanceRepeater
Definition
instancerepeater_p.h:76
qtquick3d
src
helpers
instancerepeater_p.h
Generated on
for Qt by
1.18.0