Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlproperty_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QQMLPROPERTY_P_H
5#define QQMLPROPERTY_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 "qqmlproperty.h"
19
20#include <private/qobject_p.h>
21#include <private/qqmlcontextdata_p.h>
22#include <private/qqmlpropertydata_p.h>
23#include <private/qqmlpropertyindex_p.h>
24#include <private/qqmlrefcount_p.h>
25#include <private/qtqmlglobal_p.h>
26
27#include <QtQml/qqmlengine.h>
28
29#include <QtCore/qpointer.h>
30
32
33class QQmlContext;
36class QQmlMetaObject;
39
40class Q_QML_EXPORT QQmlPropertyPrivate final : public QQmlRefCounted<QQmlPropertyPrivate>
41{
42public:
43 enum class InitFlag {
44 None = 0x0,
45 AllowId = 0x1,
46 AllowSignal = 0x2
47 };
49
50 QQmlRefPointer<QQmlContextData> context;
51 QPointer<QQmlEngine> engine;
52 QPointer<QObject> object;
53
56
58
59 // ### Qt7: Get rid of this.
60 static bool resolveUrlsOnAssignment();
61
63
65 { return encodedIndex(core, valueTypeData); }
66 static QQmlPropertyIndex encodedIndex(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData)
67 { return QQmlPropertyIndex(core.coreIndex(), valueTypeData.coreIndex()); }
68
69 QQmlRefPointer<QQmlContextData> effectiveContext() const;
70
71 void initProperty(QObject *obj, const QString &name, InitFlags flags = InitFlag::None);
72 void initDefault(QObject *obj);
73
74 bool isValueType() const;
75 QMetaType propertyType() const;
77 QQmlProperty::PropertyTypeCategory propertyTypeCategory() const;
78
79 QVariant readValueProperty();
80 bool writeValueProperty(const QVariant &, QQmlPropertyData::WriteFlags);
81
82 static QQmlMetaObject rawMetaObjectForType(QMetaType metaType);
83 static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
84 const QVariant &value, int flags);
85 static bool writeValueProperty(QObject *,
86 const QQmlPropertyData &, const QQmlPropertyData &valueTypeData,
87 const QVariant &, const QQmlRefPointer<QQmlContextData> &,
88 QQmlPropertyData::WriteFlags flags = {});
89 static bool resetValueProperty(QObject *,
90 const QQmlPropertyData &, const QQmlPropertyData &valueTypeData,
91 const QQmlRefPointer<QQmlContextData> &,
92 QQmlPropertyData::WriteFlags flags = {});
93 static bool write(QObject *, const QQmlPropertyData &, const QVariant &,
94 const QQmlRefPointer<QQmlContextData> &,
95 QQmlPropertyData::WriteFlags flags = {});
96 static bool reset(QObject *, const QQmlPropertyData &,
97 QQmlPropertyData::WriteFlags flags = {});
98 static void findAliasTarget(QObject *, QQmlPropertyIndex, QObject **, QQmlPropertyIndex *);
99
110 static ResolvedAlias findAliasTarget(QObject *baseObject, QQmlPropertyIndex baseIndex);
111
113 None = 0,
114 DontEnable = 0x1
115 };
116 Q_DECLARE_FLAGS(BindingFlags, BindingFlag)
117
118 static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None,
119 QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding);
120
121 static void removeBinding(const QQmlProperty &that);
122 static void removeBinding(QObject *o, QQmlPropertyIndex index);
123 static void removeBinding(QQmlAbstractBinding *b);
125
126 static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *,
127 const QQmlRefPointer<QQmlContextData> &);
128
129 int signalIndex() const;
130
131 static inline QQmlPropertyPrivate *get(const QQmlProperty &p) { return p.d; }
132
133 // "Public" (to QML) methods
134 static QQmlAbstractBinding *binding(const QQmlProperty &that);
135 static void setBinding(const QQmlProperty &that, QQmlAbstractBinding *);
136 static QQmlBoundSignalExpression *signalExpression(const QQmlProperty &that);
137 static void setSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
138 static void takeSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *);
139 static bool write(const QQmlProperty &that, const QVariant &, QQmlPropertyData::WriteFlags);
140 static QQmlPropertyIndex propertyIndex(const QQmlProperty &that);
141 static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
142 static QMetaProperty findPropertyByName(const QMetaObject *mo, const QByteArray &);
143 static bool connect(const QObject *sender, int signal_index,
144 const QObject *receiver, int method_index,
145 int type = 0, int *types = nullptr);
146 static void flushSignal(const QObject *sender, int signal_index);
147
148 static QList<QUrl> urlSequence(const QVariant &value);
149 static QList<QUrl> urlSequence(
150 const QVariant &value, const QQmlRefPointer<QQmlContextData> &ctxt);
151 static QQmlProperty create(
152 QObject *target, const QString &propertyName,
153 const QQmlRefPointer<QQmlContextData> &context,
154 QQmlPropertyPrivate::InitFlags flags);
155
156};
157
158Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::BindingFlags)
160
162
163#endif // QQMLPROPERTY_P_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qmetaobject.h:19
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:341
\inmodule QtCore
Definition qobject.h:103
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
QQmlPropertyData core
QQmlPropertyIndex encodedIndex() const
QQmlPropertyData valueTypeData
static QQmlPropertyPrivate * get(const QQmlProperty &p)
Q_DECLARE_FLAGS(InitFlags, InitFlag)
QQmlRefPointer< QQmlContextData > context
static QQmlPropertyIndex encodedIndex(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData)
QPointer< QQmlEngine > engine
QPointer< QObject > object
The QQmlProperty class abstracts accessing properties on objects created from QML.
Type
This enum specifies a type of QML property.
PropertyTypeCategory
This enum specifies a category of QML property.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
static void writeFlags(QTextStream &stream, const Provider &provider)
Definition ctf.cpp:269
auto signalIndex
auto mo
[7]
Combined button and popup list for selecting options.
static void * context
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
@ None
Definition qhash.cpp:531
GLboolean GLboolean GLboolean b
GLuint index
[2]
GLsizei GLenum GLenum * types
GLenum type
GLenum target
GLbitfield flags
GLuint name
GLhandleARB obj
[2]
GLboolean reset
GLfloat GLfloat p
[1]
gzip write("uncompressed data")
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
view create()
\inmodule QtCore