diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-11 16:49:55 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-12 15:46:01 +0100 |
commit | c70452a65af222343451f19ec62744314444c181 (patch) | |
tree | 10b5d1ed21b39deb82427ed12155920b7c643988 /src/qml/doc/snippets/code | |
parent | b9fcb1d4543fe19962b4cf8dcdb45c6c497e39d8 (diff) |
Doc: Modernize backend example and adapt C++ integration docs
We want people to use the static type registration.
Change-Id: I98e51af9df1a2f73df10f82458a7b7f5c5e5aad1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qml/doc/snippets/code')
-rw-r--r-- | src/qml/doc/snippets/code/backend/backend.h | 2 | ||||
-rw-r--r-- | src/qml/doc/snippets/code/backend/backend.pro | 17 | ||||
-rw-r--r-- | src/qml/doc/snippets/code/backend/main.cpp | 4 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/qml/doc/snippets/code/backend/backend.h b/src/qml/doc/snippets/code/backend/backend.h index fa7ce9eb86..6c64236bc7 100644 --- a/src/qml/doc/snippets/code/backend/backend.h +++ b/src/qml/doc/snippets/code/backend/backend.h @@ -53,11 +53,13 @@ #include <QObject> #include <QString> +#include <qqml.h> class BackEnd : public QObject { Q_OBJECT Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged) + QML_ELEMENT public: explicit BackEnd(QObject *parent = nullptr); diff --git a/src/qml/doc/snippets/code/backend/backend.pro b/src/qml/doc/snippets/code/backend/backend.pro new file mode 100644 index 0000000000..8bd2422718 --- /dev/null +++ b/src/qml/doc/snippets/code/backend/backend.pro @@ -0,0 +1,17 @@ +QT += qml + +#![registration] +CONFIG += qmltypes +QML_IMPORT_NAME = io.qt.examples.backend +QML_IMPORT_MAJOR_VERSION = 1 +#![registration] + +HEADERS += \ + backend.h + +SOURCES += \ + backend.cpp \ + main.cpp + +RESOURCES += \ + main.qml diff --git a/src/qml/doc/snippets/code/backend/main.cpp b/src/qml/doc/snippets/code/backend/main.cpp index 91a012dfda..52fcb38621 100644 --- a/src/qml/doc/snippets/code/backend/main.cpp +++ b/src/qml/doc/snippets/code/backend/main.cpp @@ -51,14 +51,10 @@ #include <QGuiApplication> #include <QQmlApplicationEngine> -#include "backend.h" - int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType<BackEnd>("io.qt.examples.backend", 1, 0, "BackEnd"); - QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); |