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
qqmlproperty.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// Qt-Security score:significant
4
5#ifndef QQMLPROPERTY_H
6#define QQMLPROPERTY_H
7
8#include <QtCore/qstring.h>
9#include <QtCore/qhashfunctions.h>
10#include <QtQml/qtqmlglobal.h>
11#include <QtCore/qmetaobject.h>
12#include <QtQml/qqmlregistration.h>
13
15
16
17class QObject;
18class QVariant;
19class QQmlContext;
20class QQmlEngine;
21
22class QQmlPropertyPrivate;
23class Q_QML_EXPORT QQmlProperty
24{
25 Q_GADGET
26 QML_ANONYMOUS
27
28 Q_PROPERTY(QObject *object READ object CONSTANT FINAL)
29 Q_PROPERTY(QString name READ name CONSTANT FINAL)
30public:
31 enum PropertyTypeCategory {
32 InvalidCategory,
33 List,
34 Object,
35 Normal
36 };
37
38 enum Type {
39 Invalid,
40 Property,
41 SignalProperty
42 };
43
44 QQmlProperty();
45 ~QQmlProperty();
46
47 QQmlProperty(QObject *);
48 QQmlProperty(QObject *, QQmlContext *);
49 QQmlProperty(QObject *, QQmlEngine *);
50
51 QQmlProperty(QObject *, const QString &);
52 QQmlProperty(QObject *, const QString &, QQmlContext *);
53 QQmlProperty(QObject *, const QString &, QQmlEngine *);
54
55 QQmlProperty(const QQmlProperty &);
56 QQmlProperty &operator=(const QQmlProperty &);
57
58 QQmlProperty(QQmlProperty &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
59 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QQmlProperty)
60
61 void swap(QQmlProperty &other) noexcept { qt_ptr_swap(d, other.d); }
62 bool operator==(const QQmlProperty &) const;
63
64 Type type() const;
65 bool isValid() const;
66 bool isProperty() const;
67 bool isSignalProperty() const;
68
69 int propertyType() const;
70 QMetaType propertyMetaType() const;
71 PropertyTypeCategory propertyTypeCategory() const;
72 const char *propertyTypeName() const;
73
74 QString name() const;
75
76 QVariant read() const;
77 static QVariant read(const QObject *, const QString &);
78 static QVariant read(const QObject *, const QString &, QQmlContext *);
79 static QVariant read(const QObject *, const QString &, QQmlEngine *);
80
81 bool write(const QVariant &) const;
82 static bool write(QObject *, const QString &, const QVariant &);
83 static bool write(QObject *, const QString &, const QVariant &, QQmlContext *);
84 static bool write(QObject *, const QString &, const QVariant &, QQmlEngine *);
85
86 bool reset() const;
87
88 bool hasNotifySignal() const;
89 bool needsNotifySignal() const;
90 bool connectNotifySignal(QObject *dest, const char *slot) const;
91 bool connectNotifySignal(QObject *dest, int method) const;
92
93 bool isWritable() const;
94 bool isBindable() const;
95 bool isDesignable() const;
96 bool isResettable() const;
97 QObject *object() const;
98
99 int index() const;
100 QMetaProperty property() const;
101 QMetaMethod method() const;
102
103private:
104 friend class QQmlPropertyPrivate;
105 QQmlPropertyPrivate *d = nullptr;
106};
108
109inline size_t qHash (const QQmlProperty &key, size_t seed = 0)
110{
111 return qHashMulti(seed, key.object(), key.name());
112}
113
114Q_DECLARE_TYPEINFO(QQmlProperty, Q_RELOCATABLE_TYPE);
115
116QT_END_NAMESPACE
117
118#endif // QQMLPROPERTY_H
qint64 writeData(const char *data, qint64 len) final
Writes up to maxSize bytes from data to the device.
qint64 readData(char *data, qint64 maxlen) final
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
void engineAboutToBeAdded(QJSEngine *) override
void messageReceived(const QByteArray &) override
void engineAboutToBeRemoved(QJSEngine *) override
QQmlDebugStatesDelegate * statesDelegate()
The QQmlProperty class abstracts accessing properties on objects created from QML.
bool removeWatch(int id)
bool addWatch(int id, quint32 objectId)
bool addWatch(int id, quint32 objectId, const QByteArray &property)
Combined button and popup list for selecting options.
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
static bool isSaveable(const QVariant &value)
static bool hasValidSignal(QObject *object, const QString &propertyName)
QDataStream & operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectProperty &)
QDataStream & operator>>(QDataStream &, QQmlEngineDebugServiceImpl::QQmlObjectData &)
QList< QQmlProperty > QQmlProperties
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
Definition qsize.h:192