diff options
author | Chris Adams <christopher.adams@nokia.com> | 2012-06-26 18:02:35 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-11 01:46:52 +0200 |
commit | f5cb65b35e076facbce45e896902a34da7036135 (patch) | |
tree | 7575065fde2d0c14c379a992bf8b3593e21f4881 /src/qml/qml/qqmlvaluetype_p.h | |
parent | 5376906de58e1c25c77b7a61800365b6e542542f (diff) |
Fix broken value-type support by allowing property definition
In QtQuick 1.x the "variant" property type was supported, which could
be used to allow value type properties to be defined in QML. In
QtQuick 2.0, we have deprecated the "variant" property, but its
replacement ("var") is not suited for defining lightweight C++ type
values (such as QColor, QFont, QRectF, QVector3D etc).
This commit allows those QML basic types to be used in QML once more,
by supporting them in the property definition syntax.
Note that since some value types are provided by QtQuick and others
are provided by QtQml, if a client imports only QtQml they can define
but not use properties of certain types (eg, font).
Task-number: QTBUG-21034
Task-number: QTBUG-18217
Change-Id: Ia951a8522f223408d27293bb96c276281a710277
Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlvaluetype_p.h')
-rw-r--r-- | src/qml/qml/qqmlvaluetype_p.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h index f704da2c8e..02be333037 100644 --- a/src/qml/qml/qqmlvaluetype_p.h +++ b/src/qml/qml/qqmlvaluetype_p.h @@ -69,7 +69,7 @@ class Q_QML_PRIVATE_EXPORT QQmlValueType : public QObject { Q_OBJECT public: - QQmlValueType(QObject *parent = 0); + QQmlValueType(int userType, QObject *parent = 0); virtual void read(QObject *, int) = 0; virtual void write(QObject *, int, QQmlPropertyPrivate::WriteFlags flags) = 0; virtual QVariant value() = 0; @@ -80,6 +80,11 @@ public: virtual void onLoad() {} + inline int userType() const + { + return m_userType; + } + protected: inline void readProperty(QObject *obj, int idx, void *p) { @@ -94,6 +99,9 @@ protected: void *a[] = { p, 0, &status, &flags }; QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a); } + +private: + int m_userType; }; template <typename T> @@ -102,8 +110,8 @@ class QQmlValueTypeBase : public QQmlValueType public: typedef T ValueType; - QQmlValueTypeBase(QObject *parent) - : QQmlValueType(parent) + QQmlValueTypeBase(int userType, QObject *parent) + : QQmlValueType(userType, parent) { } |