diff options
author | Martin Kampas <martin.kampas@jolla.com> | 2016-11-17 17:45:41 +0100 |
---|---|---|
committer | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2016-11-23 20:17:43 +0000 |
commit | 0e1f831f212cbbe9d2a3f0d5b5d471de2a55768e (patch) | |
tree | 40af7553ac8b16cf86176979e4e4ea58545d2825 | |
parent | cba633902cbb7d2557d924bd1692c03599084031 (diff) |
Example app: Ephasize more QmlLive is an addition
Stress it more that it is an addition to the application just to allow
live reloading; it is not the core of the application.
Change-Id: I6b8b8f849e60281ec5bf9217a32137d22220f7ff
Reviewed-by: Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com>
-rw-r--r-- | examples/app/main.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/examples/app/main.cpp b/examples/app/main.cpp index 80d6738..2545b02 100644 --- a/examples/app/main.cpp +++ b/examples/app/main.cpp @@ -37,39 +37,50 @@ #include "livenodeengine.h" #include "remotereceiver.h" -class CustomQmlEngine : public QQmlEngine +class MyQmlApplicationEngine : public QQmlApplicationEngine { Q_OBJECT public: - CustomQmlEngine(); // Perform some setup here + MyQmlApplicationEngine(const QString &mainQml); // Perform some setup here }; int main(int argc, char **argv) { QGuiApplication app(argc, argv); + MyQmlApplicationEngine engine(QStringLiteral("qml/window.qml")); - CustomQmlEngine qmlEngine; - QQuickView fallbackView(&qmlEngine, 0); + if (!qEnvironmentVariableIsSet("MY_APP_ENABLE_QMLLIVE")) + return app.exec(); +#if defined(QT_NO_DEBUG) + qWarning() << "QmlLive support was disabled at compile time"; +#else LiveNodeEngine node; + // Let QmlLive know your runtime - node.setQmlEngine(&qmlEngine); + node.setQmlEngine(&engine); + // Allow it to display QML components with non-QQuickWindow root object + QQuickView fallbackView(&engine, 0); node.setFallbackView(&fallbackView); + // Tell it where file updates should be stored relative to node.setWorkspace(app.applicationDirPath(), LiveNodeEngine::AllowUpdates | LiveNodeEngine::UpdatesAsOverlay); + // Listen to IPC call from remote QmlLive Bench RemoteReceiver receiver; receiver.registerNode(&node); receiver.listen(10234); +#endif + return app.exec(); } //![0] -CustomQmlEngine::CustomQmlEngine() +MyQmlApplicationEngine::MyQmlApplicationEngine(const QString &mainQml) { QStringList colors; colors.append(QStringLiteral("red")); @@ -77,6 +88,8 @@ CustomQmlEngine::CustomQmlEngine() colors.append(QStringLiteral("blue")); colors.append(QStringLiteral("black")); rootContext()->setContextProperty("myColors", colors); + + load(QDir(qApp->applicationDirPath()).absoluteFilePath(mainQml)); }; #include "main.moc" |