From c70452a65af222343451f19ec62744314444c181 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 11 Feb 2020 16:49:55 +0100 Subject: 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 Reviewed-by: Paul Wicking --- src/qml/doc/snippets/code/backend/backend.h | 2 ++ src/qml/doc/snippets/code/backend/backend.pro | 17 +++++++++++++++++ src/qml/doc/snippets/code/backend/main.cpp | 4 ---- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/qml/doc/snippets/code/backend/backend.pro (limited to 'src/qml/doc/snippets/code') 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 #include +#include 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 #include -#include "backend.h" - int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType("io.qt.examples.backend", 1, 0, "BackEnd"); - QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); -- cgit v1.2.1