diff options
Diffstat (limited to 'examples/quick/scenegraph/customgeometry')
4 files changed, 18 insertions, 7 deletions
diff --git a/examples/quick/scenegraph/customgeometry/beziercurve.h b/examples/quick/scenegraph/customgeometry/beziercurve.h index f2f7832e6d..fd0085a08e 100644 --- a/examples/quick/scenegraph/customgeometry/beziercurve.h +++ b/examples/quick/scenegraph/customgeometry/beziercurve.h @@ -64,6 +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 6f3c24e87b..0b9b2eb3f9 100644 --- a/examples/quick/scenegraph/customgeometry/main.cpp +++ b/examples/quick/scenegraph/customgeometry/main.cpp @@ -56,10 +56,9 @@ //! [1] int main(int argc, char **argv) { + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); - qmlRegisterType<BezierCurve>("CustomGeometry", 1, 0, "BezierCurve"); - QQuickView view; QSurfaceFormat format = view.format(); format.setSamples(16); |