aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml/tutorials/extending-qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-08-21 18:34:21 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-09-26 12:32:17 +0200
commitcc1a604c704f848927b3fa0a97b0a50b0b79d2a4 (patch)
tree610ece713eba021c8e5a3d248f54a62370e810f8 /examples/qml/tutorials/extending-qml
parent531cf90305ae50920b2e597dd0758fdb82ad88b0 (diff)
Specify parameters of type registration in class declarations
Using this technique we can automatically register all necessary revisions and minor versions of a type, using the metaobject system. This greatly reduces the potential for mistakes and resulting incompatibilities between versions of imports. We assume that for each type we need to register all revisions of its super types and its attached type, and that the revisions match. That is, if you import version X of type A, you will also get version X of its attached type and of any super types. As we previously didn't take these dependencies into account when manually registering the types, a number of extra revisions are now registered for some types. Potentially, we can now generate the qmltypes files at compile time, using moc. Change-Id: I7abb8a5c39f5e63ad1a0cb41a783f2c91909491b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'examples/qml/tutorials/extending-qml')
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp4
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp3
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp3
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h1
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h1
15 files changed, 15 insertions, 12 deletions
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp
index fbff60c0e6..af50cc14f2 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/main.cpp
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+ qmlRegisterTypesAndRevisions<PieChart>("Charts", 1);
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
diff --git a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h
index 005a706db6..687f8e2b4d 100644
--- a/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter1-basics/piechart.h
@@ -59,6 +59,7 @@ class PieChart : public QQuickPaintedItem
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QColor color READ color WRITE setColor)
+ QML_ELEMENT
public:
PieChart(QQuickItem *parent = 0);
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp
index fbff60c0e6..af50cc14f2 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/main.cpp
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+ qmlRegisterTypesAndRevisions<PieChart>("Charts", 1);
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
diff --git a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h
index 36bfa3ada0..271afbf653 100644
--- a/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter2-methods/piechart.h
@@ -60,7 +60,7 @@ class PieChart : public QQuickPaintedItem
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QColor color READ color WRITE setColor)
-
+ QML_ELEMENT
//![1]
public:
//![1]
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp
index fbff60c0e6..af50cc14f2 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/main.cpp
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
+ qmlRegisterTypesAndRevisions<PieChart>("Charts", 1);
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
diff --git a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h
index 9de2baa82e..58b1339298 100644
--- a/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter3-bindings/piechart.h
@@ -59,6 +59,7 @@ class PieChart : public QQuickPaintedItem
//![0]
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
+ QML_ELEMENT
//![1]
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp
index 82355d0438..7c5d1a6885 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp
@@ -59,10 +59,8 @@ int main(int argc, char *argv[])
//![0]
QGuiApplication app(argc, argv);
- qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
-
//![1]
- qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+ qmlRegisterTypesAndRevisions<PieChart, PieSlice>("Charts", 1);
//![1]
QQuickView view;
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h
index 6cd09a9293..b762ce1c49 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/piechart.h
@@ -61,7 +61,7 @@ class PieChart : public QQuickItem
Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
//![0]
Q_PROPERTY(QString name READ name WRITE setName)
-
+ QML_ELEMENT
//![1]
public:
//![1]
diff --git a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h
index 10ab4d34b6..6e64917851 100644
--- a/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h
+++ b/examples/qml/tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h
@@ -58,6 +58,7 @@ class PieSlice : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor)
+ QML_ELEMENT
public:
PieSlice(QQuickItem *parent = 0);
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp
index 8aa6fef018..70ef103e4d 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/main.cpp
@@ -57,8 +57,7 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
- qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
+ qmlRegisterTypesAndRevisions<PieChart, PieSlice>("Charts", 1);
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h
index 9b3390b902..236fa6796f 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.h
@@ -61,6 +61,7 @@ class PieChart : public QQuickItem
Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
//![0]
Q_PROPERTY(QString name READ name WRITE setName)
+ QML_ELEMENT
//![1]
public:
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h
index f8f7f7c36a..0b290851f0 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/pieslice.h
@@ -60,6 +60,7 @@ class PieSlice : public QQuickPaintedItem
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+ QML_ELEMENT
//![0]
public:
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp
index ce8b95b6b6..74d382ec57 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.cpp
@@ -55,8 +55,7 @@
void ChartsPlugin::registerTypes(const char *uri)
{
- qmlRegisterType<PieChart>(uri, 1, 0, "PieChart");
- qmlRegisterType<PieSlice>(uri, 1, 0, "PieSlice");
+ qmlRegisterTypesAndRevisions<PieChart, PieSlice>(uri, 1);
}
//![0]
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h
index cd67bdf34a..e6b768b274 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.h
@@ -59,6 +59,7 @@ class PieChart : public QQuickItem
Q_OBJECT
Q_PROPERTY(QQmlListProperty<PieSlice> slices READ slices)
Q_PROPERTY(QString name READ name WRITE setName)
+ QML_ELEMENT
public:
PieChart(QQuickItem *parent = 0);
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h
index 71cc20a369..091870bd51 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/pieslice.h
@@ -59,6 +59,7 @@ class PieSlice : public QQuickPaintedItem
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle)
Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
+ QML_ELEMENT
public:
PieSlice(QQuickItem *parent = 0);