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
qobjectregistry_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
//
5
// W A R N I N G
6
// -------------
7
//
8
// This file is not part of the Qt API. It exists purely as an
9
// implementation detail. This header file may change from version to
10
// version without notice, or even be removed.
11
//
12
// We mean it.
13
//
14
15
#
ifndef
QOBJECTREGISTRY_P_H
16
#
define
QOBJECTREGISTRY_P_H
17
18
#
include
<
QtQmlDesignSupport
/
qtqmldesignsupportexports
.
h
>
19
20
#
include
<
QtCore
/
qpointer
.
h
>
21
22
#
include
<
QtQml
/
qqml
.
h
>
23
#
include
<
QtQml
/
qqmlparserstatus
.
h
>
24
#
include
<
QtQml
/
private
/
qqmlguard_p
.
h
>
25
26
QT_BEGIN_NAMESPACE
27
28
class
QAbstractObjectRegistryRefPrivate;
29
class
QObjectRegistrySingleton;
30
31
class
Q_QMLDESIGNSUPPORT_EXPORT
QObjectRegistryAttachedType
32
:
public
QObject,
public
QQmlParserStatus
33
{
34
Q_OBJECT
35
Q_INTERFACES(QQmlParserStatus)
36
37
Q_PROPERTY(QString key READ key WRITE setKey NOTIFY keyChanged FINAL)
38
39
QML_ANONYMOUS
40
41
public
:
42
QObjectRegistryAttachedType(QObject *parent =
nullptr
);
43
~QObjectRegistryAttachedType();
44
45
QString key()
const
;
46
void
setKey(
const
QString &key);
47
48
void
classBegin() override;
49
void
componentComplete() override;
50
51
Q_SIGNALS:
52
void
keyChanged();
53
54
private
:
55
QString m_key;
56
bool
m_qmlSetupInProgress =
false
;
57
QPointer<QObjectRegistrySingleton> m_registry;
58
};
59
60
class
Q_QMLDESIGNSUPPORT_EXPORT
QObjectRegistry
:
public
QObject
61
{
62
Q_OBJECT
63
64
Q_PROPERTY(QString key READ key WRITE setKey NOTIFY keyChanged REQUIRED FINAL)
65
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged REQUIRED FINAL)
66
67
QML_ATTACHED(QObjectRegistryAttachedType)
68
69
QML_NAMED_ELEMENT(ObjectRegistry)
70
71
public
:
72
QObjectRegistry(QObject *parent =
nullptr
);
73
~QObjectRegistry();
74
75
static
QObjectRegistryAttachedType *qmlAttachedProperties(QObject *object);
76
77
QString key()
const
;
78
void
setKey(
const
QString &key);
79
80
QObject *target()
const
;
81
void
setTarget(QObject *target);
82
83
Q_SIGNALS:
84
void
keyChanged();
85
void
targetChanged();
86
87
private
:
88
class
TargetGuard :
public
QQmlGuard<QObject>
89
{
90
public
:
91
explicit
TargetGuard(QObjectRegistry *owner)
92
: QQmlGuard<QObject>(&TargetGuard::objectDestroyedImpl,
nullptr
)
93
, m_owner(owner)
94
{
95
}
96
97
private
:
98
static
void
objectDestroyedImpl(QQmlGuardImpl *guard)
99
{
100
TargetGuard *self =
static_cast
<TargetGuard *>(guard);
101
emit self->m_owner->targetChanged();
102
}
103
104
QObjectRegistry *m_owner =
nullptr
;
105
};
106
107
QString m_key;
108
TargetGuard m_target {
this
};
109
QPointer<QObjectRegistrySingleton> m_registry;
110
};
111
112
QT_END_NAMESPACE
113
114
#
endif
// QOBJECTREGISTRY_P_H
QObjectRegistryAttachedType
Definition
qobjectregistry_p.h:33
QObjectRegistry
Definition
qobjectregistry_p.h:61
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
qmldesignsupport
qobjectregistry_p.h
Generated on
for Qt by
1.18.0