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
4#ifndef QQMLPROPERTY_H
5#define QQMLPROPERTY_H
6
7#include <QtCore/qstring.h>
8#include <QtCore/qhashfunctions.h>
9#include <QtQml/qtqmlglobal.h>
10#include <QtCore/qmetaobject.h>
11#include <QtQml/qqmlregistration.h>
12
14
15
16class QObject;
17class QVariant;
18class QQmlContext;
19class QQmlEngine;
20
21class QQmlPropertyPrivate;
22class Q_QML_EXPORT QQmlProperty
23{
24 Q_GADGET
25 QML_ANONYMOUS
26
27 Q_PROPERTY(QObject *object READ object CONSTANT FINAL)
28 Q_PROPERTY(QString name READ name CONSTANT FINAL)
29public:
30 enum PropertyTypeCategory {
31 InvalidCategory,
32 List,
33 Object,
34 Normal
35 };
36
37 enum Type {
38 Invalid,
39 Property,
40 SignalProperty
41 };
42
43 QQmlProperty();
44 ~QQmlProperty();
45
46 QQmlProperty(QObject *);
47 QQmlProperty(QObject *, QQmlContext *);
48 QQmlProperty(QObject *, QQmlEngine *);
49
50 QQmlProperty(QObject *, const QString &);
51 QQmlProperty(QObject *, const QString &, QQmlContext *);
52 QQmlProperty(QObject *, const QString &, QQmlEngine *);
53
54 QQmlProperty(const QQmlProperty &);
55 QQmlProperty &operator=(const QQmlProperty &);
56
57 QQmlProperty(QQmlProperty &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
58 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QQmlProperty)
59
60 void swap(QQmlProperty &other) noexcept { qt_ptr_swap(d, other.d); }
61 bool operator==(const QQmlProperty &) const;
62
63 Type type() const;
64 bool isValid() const;
65 bool isProperty() const;
66 bool isSignalProperty() const;
67
68 int propertyType() const;
69 QMetaType propertyMetaType() const;
70 PropertyTypeCategory propertyTypeCategory() const;
71 const char *propertyTypeName() const;
72
73 QString name() const;
74
75 QVariant read() const;
76 static QVariant read(const QObject *, const QString &);
77 static QVariant read(const QObject *, const QString &, QQmlContext *);
78 static QVariant read(const QObject *, const QString &, QQmlEngine *);
79
80 bool write(const QVariant &) const;
81 static bool write(QObject *, const QString &, const QVariant &);
82 static bool write(QObject *, const QString &, const QVariant &, QQmlContext *);
83 static bool write(QObject *, const QString &, const QVariant &, QQmlEngine *);
84
85 bool reset() const;
86
87 bool hasNotifySignal() const;
88 bool needsNotifySignal() const;
89 bool connectNotifySignal(QObject *dest, const char *slot) const;
90 bool connectNotifySignal(QObject *dest, int method) const;
91
92 bool isWritable() const;
93 bool isBindable() const;
94 bool isDesignable() const;
95 bool isResettable() const;
96 QObject *object() const;
97
98 int index() const;
99 QMetaProperty property() const;
100 QMetaMethod method() const;
101
102private:
103 friend class QQmlPropertyPrivate;
104 QQmlPropertyPrivate *d = nullptr;
105};
107
108inline size_t qHash (const QQmlProperty &key, size_t seed = 0)
109{
110 return qHashMulti(seed, key.object(), key.name());
111}
112
113Q_DECLARE_TYPEINFO(QQmlProperty, Q_RELOCATABLE_TYPE);
114
115QT_END_NAMESPACE
116
117#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:181