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
qqmlvaluetype_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 QQMLVALUETYPE_P_H
5#define QQMLVALUETYPE_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 <QtQml/private/qqmlproperty_p.h>
19
20#include <private/qqmlnullablevalue_p.h>
21#include <private/qmetatype_p.h>
22#include <private/qv4referenceobject_p.h>
23
24#include <QtCore/qobject.h>
25#include <QtCore/qrect.h>
26#if QT_CONFIG(easingcurve)
27#include <QtCore/qeasingcurve.h>
28#endif
29#include <QtCore/qvariant.h>
30
32
33class Q_QML_EXPORT QQmlValueType : public QDynamicMetaObjectData
34{
35public:
36 QQmlValueType() = default;
37 QQmlValueType(QMetaType type, const QMetaObject *staticMetaObject)
38 : m_metaType(type), m_staticMetaObject(staticMetaObject)
39 {}
41
42 void *create() const { return m_metaType.create(); }
43 void destroy(void *gadgetPtr) const { m_metaType.destroy(gadgetPtr); }
44
45 void construct(void *gadgetPtr, const void *copy) const { m_metaType.construct(gadgetPtr, copy); }
46 void destruct(void *gadgetPtr) const { m_metaType.destruct(gadgetPtr); }
47
48 QMetaType metaType() const { return m_metaType; }
49 const QMetaObject *staticMetaObject() const { return m_staticMetaObject; }
50
51 // ---- dynamic meta object data interface
52 QMetaObject *toDynamicMetaObject(QObject *) override;
53 void objectDestroyed(QObject *) override;
54 int metaCall(QObject *obj, QMetaObject::Call type, int _id, void **argv) override;
55 // ----
56
57private:
58 QMetaType m_metaType;
59 const QMetaObject *m_staticMetaObject = nullptr;
60 QMetaObject *m_dynamicMetaObject = nullptr;
61};
62
63class Q_QML_EXPORT QQmlGadgetPtrWrapper : public QObject
64{
66public:
68
69 QQmlGadgetPtrWrapper(QQmlValueType *valueType, QObject *parent = nullptr);
71
72 void read(QObject *obj, int idx);
73 void write(QObject *obj, int idx, QQmlPropertyData::WriteFlags flags,
74 int internalIndex = QV4::ReferenceObject::AllProperties) const;
75 QVariant value() const;
76 void setValue(const QVariant &value);
77
78 QMetaType metaType() const { return valueType()->metaType(); }
79 int metaCall(QMetaObject::Call type, int id, void **argv);
80
82 {
83 return valueType()->staticMetaObject()->property(index);
84 }
85
87 {
88 return property.readOnGadget(m_gadgetPtr);
89 }
90
92 {
93 property.writeOnGadget(m_gadgetPtr, value);
94 }
95
97 {
98 property.writeOnGadget(m_gadgetPtr, std::move(value));
99 }
100
101private:
102 const QQmlValueType *valueType() const;
103 void *m_gadgetPtr = nullptr;
104};
105
106struct Q_QML_EXPORT QQmlPointFValueType
107{
109 Q_PROPERTY(qreal x READ x WRITE setX FINAL)
110 Q_PROPERTY(qreal y READ y WRITE setY FINAL)
112 QML_VALUE_TYPE(point)
117
118public:
120 Q_INVOKABLE QQmlPointFValueType(const QPoint &point) : v(point) {}
122 qreal x() const;
123 qreal y() const;
124 void setX(qreal);
125 void setY(qreal);
126
127 operator QPointF() const { return v; }
128};
129
130struct Q_QML_EXPORT QQmlPointValueType
131{
133 Q_PROPERTY(int x READ x WRITE setX FINAL)
134 Q_PROPERTY(int y READ y WRITE setY FINAL)
141
142public:
144 Q_INVOKABLE QQmlPointValueType(const QPointF &point) : v(point.toPoint()) {}
146 int x() const;
147 int y() const;
148 void setX(int);
149 void setY(int);
150
151 operator QPoint() const { return v; }
152};
153
154struct Q_QML_EXPORT QQmlSizeFValueType
155{
157 Q_PROPERTY(qreal width READ width WRITE setWidth FINAL)
158 Q_PROPERTY(qreal height READ height WRITE setHeight FINAL)
165
166public:
170 qreal width() const;
171 qreal height() const;
172 void setWidth(qreal);
173 void setHeight(qreal);
174
175 operator QSizeF() const { return v; }
176};
177
178struct Q_QML_EXPORT QQmlSizeValueType
179{
181 Q_PROPERTY(int width READ width WRITE setWidth FINAL)
182 Q_PROPERTY(int height READ height WRITE setHeight FINAL)
189
190public:
191 QQmlSizeValueType() = default;
194 int width() const;
195 int height() const;
196 void setWidth(int);
197 void setHeight(int);
198
199 operator QSize() const { return v; }
200};
201
202struct Q_QML_EXPORT QQmlRectFValueType
203{
205 Q_PROPERTY(qreal x READ x WRITE setX FINAL)
206 Q_PROPERTY(qreal y READ y WRITE setY FINAL)
207 Q_PROPERTY(qreal width READ width WRITE setWidth FINAL)
208 Q_PROPERTY(qreal height READ height WRITE setHeight FINAL)
209 Q_PROPERTY(qreal left READ left DESIGNABLE false FINAL)
210 Q_PROPERTY(qreal right READ right DESIGNABLE false FINAL)
211 Q_PROPERTY(qreal top READ top DESIGNABLE false FINAL)
212 Q_PROPERTY(qreal bottom READ bottom DESIGNABLE false FINAL)
219
220public:
224 qreal x() const;
225 qreal y() const;
226 void setX(qreal);
227 void setY(qreal);
228
229 qreal width() const;
230 qreal height() const;
231 void setWidth(qreal);
232 void setHeight(qreal);
233
234 qreal left() const;
235 qreal right() const;
236 qreal top() const;
237 qreal bottom() const;
238
239 operator QRectF() const { return v; }
240};
241
242struct Q_QML_EXPORT QQmlRectValueType
243{
245 Q_PROPERTY(int x READ x WRITE setX FINAL)
246 Q_PROPERTY(int y READ y WRITE setY FINAL)
247 Q_PROPERTY(int width READ width WRITE setWidth FINAL)
248 Q_PROPERTY(int height READ height WRITE setHeight FINAL)
249 Q_PROPERTY(int left READ left DESIGNABLE false FINAL)
250 Q_PROPERTY(int right READ right DESIGNABLE false FINAL)
251 Q_PROPERTY(int top READ top DESIGNABLE false FINAL)
252 Q_PROPERTY(int bottom READ bottom DESIGNABLE false FINAL)
259
260public:
261 QQmlRectValueType() = default;
264 int x() const;
265 int y() const;
266 void setX(int);
267 void setY(int);
268
269 int width() const;
270 int height() const;
271 void setWidth(int);
272 void setHeight(int);
273
274 int left() const;
275 int right() const;
276 int top() const;
277 int bottom() const;
278
279 operator QRect() const { return v; }
280};
281
282#if QT_CONFIG(easingcurve)
283namespace QQmlEasingEnums
284{
285Q_NAMESPACE_EXPORT(Q_QML_EXPORT)
286QML_NAMED_ELEMENT(Easing)
288
289enum Type {
292 InOutQuad = QEasingCurve::InOutQuad, OutInQuad = QEasingCurve::OutInQuad,
293 InCubic = QEasingCurve::InCubic, OutCubic = QEasingCurve::OutCubic,
294 InOutCubic = QEasingCurve::InOutCubic, OutInCubic = QEasingCurve::OutInCubic,
295 InQuart = QEasingCurve::InQuart, OutQuart = QEasingCurve::OutQuart,
296 InOutQuart = QEasingCurve::InOutQuart, OutInQuart = QEasingCurve::OutInQuart,
297 InQuint = QEasingCurve::InQuint, OutQuint = QEasingCurve::OutQuint,
298 InOutQuint = QEasingCurve::InOutQuint, OutInQuint = QEasingCurve::OutInQuint,
300 InOutSine = QEasingCurve::InOutSine, OutInSine = QEasingCurve::OutInSine,
302 InOutExpo = QEasingCurve::InOutExpo, OutInExpo = QEasingCurve::OutInExpo,
304 InOutCirc = QEasingCurve::InOutCirc, OutInCirc = QEasingCurve::OutInCirc,
305 InElastic = QEasingCurve::InElastic, OutElastic = QEasingCurve::OutElastic,
306 InOutElastic = QEasingCurve::InOutElastic, OutInElastic = QEasingCurve::OutInElastic,
308 InOutBack = QEasingCurve::InOutBack, OutInBack = QEasingCurve::OutInBack,
309 InBounce = QEasingCurve::InBounce, OutBounce = QEasingCurve::OutBounce,
310 InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce,
311 InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve,
312 SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve,
313 BezierSpline = QEasingCurve::BezierSpline,
314
315 Bezier = BezierSpline // Evil! Don't use this!
316};
318};
319
320struct Q_QML_EXPORT QQmlEasingValueType
321{
327 QML_EXTENDED(QQmlEasingValueType)
329
330 Q_PROPERTY(QQmlEasingEnums::Type type READ type WRITE setType FINAL)
331 Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude FINAL)
332 Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot FINAL)
333 Q_PROPERTY(qreal period READ period WRITE setPeriod FINAL)
334 Q_PROPERTY(QVariantList bezierCurve READ bezierCurve WRITE setBezierCurve FINAL)
335
336public:
337 QQmlEasingEnums::Type type() const;
338 qreal amplitude() const;
339 qreal overshoot() const;
340 qreal period() const;
341 void setType(QQmlEasingEnums::Type);
342 void setAmplitude(qreal);
343 void setOvershoot(qreal);
344 void setPeriod(qreal);
345 void setBezierCurve(const QVariantList &);
346 QVariantList bezierCurve() const;
347
348 operator QEasingCurve() const { return v; }
349};
350#endif
351
359
361
362#endif // QQMLVALUETYPE_P_H
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:341
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
void writeOnGadget(const QMetaProperty &property, QVariant &&value)
QMetaProperty property(int index) const
QVariant readOnGadget(const QMetaProperty &property) const
QMetaType metaType() const
void writeOnGadget(const QMetaProperty &property, const QVariant &value)
void construct(void *gadgetPtr, const void *copy) const
QQmlValueType()=default
void * create() const
QQmlValueType(QMetaType type, const QMetaObject *staticMetaObject)
const QMetaObject * staticMetaObject() const
void destruct(void *gadgetPtr) const
void destroy(void *gadgetPtr) const
QMetaType metaType() const
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
rect
[4]
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble right
GLint GLsizei width
GLint left
GLenum type
GLint GLint bottom
GLbitfield flags
GLint y
GLhandleARB obj
[2]
#define QML_ANONYMOUS
#define QML_EXTENDED(EXTENDED_TYPE)
#define QML_VALUE_TYPE(NAME)
#define QML_NAMED_ELEMENT(NAME)
#define QML_FOREIGN(FOREIGN_TYPE)
#define QML_STRUCTURED_VALUE
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_GADGET
#define Q_ENUM_NS(x)
#define Q_NAMESPACE_EXPORT(...)
double qreal
Definition qtypes.h:187
ReturnedValue read(const char *data)
const char property[13]
Definition qwizard.cpp:101
gzip write("uncompressed data")
settings setValue("DataPump/bgcolor", color)
p setX(p.x()+1)
proxy setType(QNetworkProxy::Socks5Proxy)
char * toString(const MyType &t)
[31]
QJSEngine engine
[0]
\inmodule QtCore
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
static constexpr const int AllProperties
Definition moc.h:23