Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qobjectregistrysingleton_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 QOBJECTREGISTRYSINGLETON_P_H
16#define QOBJECTREGISTRYSINGLETON_P_H
17
18#include <QtQmlDesignSupport/qtqmldesignsupportexports.h>
19
20#include <QtCore/qhash.h>
21#include <QtCore/qobject.h>
22#include <QtCore/qset.h>
23#include <QtCore/qstring.h>
24#include <QtQml/qqml.h>
25
26QT_BEGIN_NAMESPACE
27
28class QAbstractObjectRegistryRefPrivate;
29class QQmlEngine;
30
31class Q_QMLDESIGNSUPPORT_EXPORT QObjectRegistrySingleton : public QObject
32{
33 Q_OBJECT
34 QML_SINGLETON
35 QML_NAMED_ELEMENT(InternalObjectRegistry)
36
37public:
38 explicit QObjectRegistrySingleton(QObject *parent = nullptr);
39
40 void registerRef(QAbstractObjectRegistryRefPrivate *ref);
41 void deregisterRef(QAbstractObjectRegistryRefPrivate *ref);
42
43 void add(const QString &key, QObject *obj);
44 void remove(const QString &key, QObject *obj);
45 QSet<QObject*> objects(const QString &key) const;
46
47 static QObjectRegistrySingleton *registryForObject(QObject *obj);
48 static QObjectRegistrySingleton *registryForEngine(QQmlEngine *engine);
49
50private:
51 QHash<QString, QSet<QObject *>> m_objects;
52 QHash<QString, QSet<QAbstractObjectRegistryRefPrivate *>> m_refs;
53};
54
55QT_END_NAMESPACE
56
57#endif // QOBJECTREGISTRYSINGLETON_P_H
Combined button and popup list for selecting options.