Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmlmetaobject_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 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#ifndef QQMLMETAOBJECT_P_H
5#define QQMLMETAOBJECT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qqmlpropertycache_p.h>
19
20#include <QtQml/qtqmlglobal.h>
21#include <QtCore/qvarlengtharray.h>
22#include <QtCore/qmetaobject.h>
23
25
26// QQmlMetaObject serves as a wrapper around either QMetaObject or QQmlPropertyCache.
27// This is necessary as we delay creation of QMetaObject for synthesized QObjects, but
28// we don't want to needlessly generate QQmlPropertyCaches every time we encounter a
29// QObject type used in assignment or when we don't have a QQmlEngine etc.
30//
31// This class does NOT reference the propertycache.
34class Q_QML_EXPORT QQmlMetaObject
35{
36public:
38
39 inline QQmlMetaObject() = default;
40 inline QQmlMetaObject(const QObject *);
41 inline QQmlMetaObject(const QMetaObject *);
43 inline QQmlMetaObject(const QQmlMetaObject &);
44
45 inline QQmlMetaObject &operator=(const QQmlMetaObject &);
46
47 inline bool isNull() const;
48
49 inline const char *className() const;
50 inline int propertyCount() const;
51
52 inline const QMetaObject *metaObject() const;
53
54 QMetaType methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const;
60 bool methodParameterTypes(int index, ArgTypeStorage *argStorage,
61 QByteArray *unknownTypeError) const;
67 bool constructorParameterTypes(int index, ArgTypeStorage *dummy, QByteArray *unknownTypeError) const;
68
69
70 static bool canConvert(const QQmlMetaObject &from, const QQmlMetaObject &to)
71 {
72 Q_ASSERT(!from.isNull() && !to.isNull());
73 return from.metaObject()->inherits(to.metaObject());
74 }
75
76 // static_metacall (on Gadgets) doesn't call the base implementation and therefore
77 // we need a helper to find the correct meta object and property/method index.
78 static void resolveGadgetMethodOrPropertyIndex(QMetaObject::Call type, const QMetaObject **metaObject, int *index);
79
80 static bool methodParameterTypes(const QMetaMethod &method, ArgTypeStorage *argStorage,
81 QByteArray *unknownTypeError);
82protected:
83 const QMetaObject *_m = nullptr;
84
85};
86
88{
89 if (o)
90 _m = o->metaObject();
91}
92
94 : _m(m)
95{
96}
97
99{
100 if (m)
101 _m = m->createMetaObject();
102}
103
105 : _m(o._m)
106{
107}
108
110{
111 _m = o._m;
112 return *this;
113}
114
116{
117 return !_m;
118}
119
120const char *QQmlMetaObject::className() const
121{
122 if (!_m)
123 return nullptr;
124 return metaObject()->className();
125}
126
128{
129 if (!_m)
130 return 0;
131 return metaObject()->propertyCount();
132}
133
135{
136 return _m;
137}
138
140
141#endif // QQMLMETAOBJECT_P_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qmetaobject.h:18
\inmodule QtCore
Definition qmetatype.h:320
\inmodule QtCore
Definition qobject.h:90
bool isNull() const
const char * className() const
QVarLengthArray< QMetaType, 9 > ArgTypeStorage
QQmlMetaObject & operator=(const QQmlMetaObject &)
const QMetaObject * metaObject() const
static bool canConvert(const QQmlMetaObject &from, const QQmlMetaObject &to)
QQmlMetaObject()=default
const QMetaObject * _m
int propertyCount() const
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
const GLfloat * m
GLuint index
[2]
GLenum type
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
const char className[16]
[1]
Definition qwizard.cpp:100
obj metaObject() -> className()
\inmodule QtCore
int propertyCount() const
Returns the number of properties in this class, including the number of properties provided by each b...
const char * className() const
Returns the class name.
bool inherits(const QMetaObject *metaObject) const noexcept
Returns true if the class described by this QMetaObject inherits the type described by metaObject; ot...