diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-12 17:03:52 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-01-13 16:47:57 +0100 |
commit | 2c3419e127e55810da1741725b4ff39f118cd577 (patch) | |
tree | 670ec93d28dadad06bd840a5694935ef8a7b2ac0 /examples/quick/scenegraph/customgeometry | |
parent | 4eff7299501ff932071300b3fa34fbeccb03d0d8 (diff) |
Generate registrations for all examples
Now that we can generate all QML type information at build time, we
should also use it.
Change-Id: I647c72bbe38fdb2deb565b75c86a696af3d15b61
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'examples/quick/scenegraph/customgeometry')
4 files changed, 16 insertions, 7 deletions
diff --git a/examples/quick/scenegraph/customgeometry/beziercurve.h b/examples/quick/scenegraph/customgeometry/beziercurve.h index be9e4ef49f..fd0085a08e 100644 --- a/examples/quick/scenegraph/customgeometry/beziercurve.h +++ b/examples/quick/scenegraph/customgeometry/beziercurve.h @@ -64,7 +64,9 @@ class BezierCurve : public QQuickItem Q_PROPERTY(QPointF p4 READ p4 WRITE setP4 NOTIFY p4Changed) Q_PROPERTY(int segmentCount READ segmentCount WRITE setSegmentCount NOTIFY segmentCountChanged) +//! [3] QML_ELEMENT +//! [3] public: BezierCurve(QQuickItem *parent = 0); diff --git a/examples/quick/scenegraph/customgeometry/customgeometry.pro b/examples/quick/scenegraph/customgeometry/customgeometry.pro index 17c30fc560..3785f88c7e 100644 --- a/examples/quick/scenegraph/customgeometry/customgeometry.pro +++ b/examples/quick/scenegraph/customgeometry/customgeometry.pro @@ -1,6 +1,10 @@ TARGET = customgeometry QT += quick +CONFIG += qmltypes +QML_IMPORT_NAME = CustomGeometry +QML_IMPORT_MAJOR_VERSION = 1 + SOURCES += \ main.cpp \ beziercurve.cpp diff --git a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc index 959114b424..bd235e5dfb 100644 --- a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc +++ b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc @@ -169,11 +169,16 @@ \snippet scenegraph/customgeometry/main.cpp 1 The application is a straightforward QML application, with a - QGuiApplication and a QQuickView that we pass a .qml file. To make - use of the BezierCurve item, we need to register it in the QML - engine, using the qmlRegisterType() function. We give it the name - BezierCurve and make it part of the \c {CustomGeometry 1.0} - module. + QGuiApplication and a QQuickView that we pass a .qml file. + + \snippet scenegraph/customgeometry/beziercurve.h 3 + + To make use of the BezierCurve item, we need to register it in the QML + engine, using the QML_ELEMENT macro. This gives it the name + BezierCurve and makes it part of the \c {CustomGeometry 1.0} + module as defined in the customgeometry.pro file: + + \quotefile scenegraph/customgeometry/customgeometry.pro As the bezier curve is drawn using GL_LINE_STRIP, we specify that the view should be multisampled to get antialiasing. This is not diff --git a/examples/quick/scenegraph/customgeometry/main.cpp b/examples/quick/scenegraph/customgeometry/main.cpp index 9352e4bd24..15310d279f 100644 --- a/examples/quick/scenegraph/customgeometry/main.cpp +++ b/examples/quick/scenegraph/customgeometry/main.cpp @@ -58,8 +58,6 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qmlRegisterTypesAndRevisions<BezierCurve>("CustomGeometry", 1); - QQuickView view; QSurfaceFormat format = view.format(); format.setSamples(16); |