From 75c119b6fafc24deb829d7badb62954a81c820c1 Mon Sep 17 00:00:00 2001 From: Svetlana Abramenkova Date: Mon, 18 Feb 2019 09:21:05 +0300 Subject: Documentation for QML Live example app Change-Id: I96d798791ccfdb581c7c4b80bfd55fc8327448ef Fixes: AUTOSUITE-777 Reviewed-by: Kavindra Palaraja --- doc/examples.qdoc | 1 + doc/examples/customruntime.qdoc | 66 ++++++++++ doc/images/customruntime-example.png | Bin 0 -> 13274 bytes doc/usage.qdoc | 2 +- examples/app/app.pro | 23 ---- examples/app/icon.png | Bin 135 -> 0 bytes examples/app/main.cpp | 133 --------------------- examples/app/qml/customruntime-item.qml | 54 --------- examples/app/qml/customruntime-window.qml | 64 ---------- examples/app/qml/item.qml | 54 --------- examples/app/qml/window.qml | 64 ---------- examples/customruntime/customruntime.pro | 23 ++++ examples/customruntime/icon.png | Bin 0 -> 135 bytes examples/customruntime/main.cpp | 133 +++++++++++++++++++++ examples/customruntime/qml/customruntime-item.qml | 56 +++++++++ .../customruntime/qml/customruntime-window.qml | 66 ++++++++++ examples/examples.pro | 2 +- 17 files changed, 347 insertions(+), 394 deletions(-) create mode 100644 doc/examples/customruntime.qdoc create mode 100644 doc/images/customruntime-example.png delete mode 100644 examples/app/app.pro delete mode 100644 examples/app/icon.png delete mode 100644 examples/app/main.cpp delete mode 100644 examples/app/qml/customruntime-item.qml delete mode 100644 examples/app/qml/customruntime-window.qml delete mode 100644 examples/app/qml/item.qml delete mode 100644 examples/app/qml/window.qml create mode 100644 examples/customruntime/customruntime.pro create mode 100644 examples/customruntime/icon.png create mode 100644 examples/customruntime/main.cpp create mode 100644 examples/customruntime/qml/customruntime-item.qml create mode 100644 examples/customruntime/qml/customruntime-window.qml diff --git a/doc/examples.qdoc b/doc/examples.qdoc index c13b2f1..04eb651 100644 --- a/doc/examples.qdoc +++ b/doc/examples.qdoc @@ -37,6 +37,7 @@ \list \li \l{contentplugin}{Content Plugin} + \li \l{customruntime}{Custom Runtime} \endlist */ diff --git a/doc/examples/customruntime.qdoc b/doc/examples/customruntime.qdoc new file mode 100644 index 0000000..fdd2e2f --- /dev/null +++ b/doc/examples/customruntime.qdoc @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ +/*! +\example customruntime +\title Custom Runtime Example + +\brief Demonstrates how to create a Custom QmlLive Runtime + +\image customruntime-example.png Screenshot of the Custom QmlLive Runtime + +Creating a custom runtime with QmlLive features allows you to use your QML +view setup, combined with additional C++ code and the QmlLive system. + +Start with the \l LiveNodeEngine class. We need to modify this class to be +able to receive workspace changes and active document updates. By default, +the IPC listens to port 10234. + +The code snippet below shows a minimal custom QmlLive runtime: + +\snippet customruntime/main.cpp 0 + +To specify project depedencies on platforms that support \c pkg-config, +add the following line to your project file. This is assuming QmlLive is +installed on your build host: + +\code +CONFIG += link_pkgconfig +PKGCONFIG += qmllive +\endcode + +In case if your system doesn't support \c pkg-config, to compile everything +directly into your application, include file \c{$(QMLLIVEPROJECT)/src/src.pri} +by adding the line into your project file: + +\code +include(src.pri) +\endcode +*/ diff --git a/doc/images/customruntime-example.png b/doc/images/customruntime-example.png new file mode 100644 index 0000000..d5aba33 Binary files /dev/null and b/doc/images/customruntime-example.png differ diff --git a/doc/usage.qdoc b/doc/usage.qdoc index ff4eeef..1fa6d17 100644 --- a/doc/usage.qdoc +++ b/doc/usage.qdoc @@ -184,7 +184,7 @@ on the port 10234. Here is a short example of a minimal custom QmlLive runtime: -\snippet ../examples/app/main.cpp 0 +\snippet ../examples/customruntime/main.cpp 0 On platforms where pkg-config is supported simply add the following to your project file if QmlLive is installed on your build host: diff --git a/examples/app/app.pro b/examples/app/app.pro deleted file mode 100644 index bb53fb3..0000000 --- a/examples/app/app.pro +++ /dev/null @@ -1,23 +0,0 @@ -TEMPLATE = app -TARGET = app -CONFIG += c++11 - -macx*: CONFIG -= app_bundle -QT *= quick - -include(../../src/lib.pri) - -SOURCES += main.cpp - -target.path = $$EXAMPLES_PREFIX/app -INSTALLS += target - -qml.files = qml/*.qml -qml.path = $$target.path/qml -INSTALLS += qml -OTHER_FILES += $$qml.files - -icon.files = icon.png -icon.path = $$target.path -INSTALLS += icon -OTHER_FILES += $$icon.files diff --git a/examples/app/icon.png b/examples/app/icon.png deleted file mode 100644 index 1bf2581..0000000 Binary files a/examples/app/icon.png and /dev/null differ diff --git a/examples/app/main.cpp b/examples/app/main.cpp deleted file mode 100644 index 9ddf336..0000000 --- a/examples/app/main.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Luxoft Sweden AB -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QmlLive tool. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite licenses may use -** this file in accordance with the commercial license agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and The Qt Company. For -** licensing terms and conditions see https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -//![0] -#include -#include - -// Use QmlLive headers -#include "livenodeengine.h" -#include "remotereceiver.h" - -class MyQmlApplicationEngine : public QQmlApplicationEngine -{ - Q_OBJECT - -public: - MyQmlApplicationEngine(const QString &mainQml); // Perform some setup here - - QString mainQml() const; - QQuickWindow *mainWindow(); - QList warnings() const; - - // ... -}; - -int main(int argc, char **argv) -{ - QGuiApplication app(argc, argv); - MyQmlApplicationEngine engine(QStringLiteral("qml/window.qml")); - - 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(&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); - - // Advanced use: let it know the initially loaded QML component (do this - // only after registering to receiver!) - node.usePreloadedDocument(engine.mainQml(), engine.mainWindow(), engine.warnings()); -#endif - - return app.exec(); -} -//![0] - -// Keep the snippet simple! -static QString MyQmlApplicationEngine_mainQml; -static QList MyQmlApplicationEngine_warnings; - -MyQmlApplicationEngine::MyQmlApplicationEngine(const QString &mainQml) -{ - // Would be nice to have this in QQmlApplicationEngine - MyQmlApplicationEngine_mainQml = mainQml; - connect(this, &QQmlEngine::warnings, [](const QList &warnings) { - MyQmlApplicationEngine_warnings.append(warnings); - }); - - QStringList colors; - colors.append(QStringLiteral("red")); - colors.append(QStringLiteral("green")); - colors.append(QStringLiteral("blue")); - colors.append(QStringLiteral("black")); - rootContext()->setContextProperty("myColors", colors); - - load(QDir(qApp->applicationDirPath()).absoluteFilePath(mainQml)); -}; - -QString MyQmlApplicationEngine::mainQml() const -{ - return MyQmlApplicationEngine_mainQml; -} - -QQuickWindow *MyQmlApplicationEngine::mainWindow() -{ - if (rootObjects().isEmpty()) - return nullptr; - - return qobject_cast(rootObjects().first()); -} - -QList MyQmlApplicationEngine::warnings() const -{ - return MyQmlApplicationEngine_warnings; -} - -#include "main.moc" diff --git a/examples/app/qml/customruntime-item.qml b/examples/app/qml/customruntime-item.qml deleted file mode 100644 index 68e4303..0000000 --- a/examples/app/qml/customruntime-item.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Luxoft Sweden AB -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QmlLive tool. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite licenses may use -** this file in accordance with the commercial license agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and The Qt Company. For -** licensing terms and conditions see https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - - model: myColors - delegate: Rectangle { - width: ListView.view.width - height: 25 - color: model.modelData - Image { - anchors.left: parent.left - source: "../icon.png" - } - Text { - x: 25 - text: model.modelData - color: "white" - } - } -} diff --git a/examples/app/qml/customruntime-window.qml b/examples/app/qml/customruntime-window.qml deleted file mode 100644 index 4818a04..0000000 --- a/examples/app/qml/customruntime-window.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Luxoft Sweden AB -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QmlLive tool. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite licenses may use -** this file in accordance with the commercial license agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and The Qt Company. For -** licensing terms and conditions see https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.2 - -Window { - id: window - width: 100 - height: 100 - visible: true - - ListView { - // TODO: Make it work with 'anchors.fill: parent'. Window size seems to - // be propagated too late to the contentItem, giving zero size initially. - width: window.width - height: window.height - - model: myColors - delegate: Rectangle { - width: ListView.view.width - height: 25 - color: model.modelData - Image { - anchors.left: parent.left - source: "../icon.png" - } - Text { - x: 25 - text: model.modelData - color: "white" - } - } - } -} diff --git a/examples/app/qml/item.qml b/examples/app/qml/item.qml deleted file mode 100644 index 85258c1..0000000 --- a/examples/app/qml/item.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Luxoft Sweden AB -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QmlLive tool. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite licenses may use -** this file in accordance with the commercial license agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and The Qt Company. For -** licensing terms and conditions see https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - - model: ["red", "green", "blue", "black"] - delegate: Rectangle { - width: ListView.view.width - height: 25 - color: model.modelData - Image { - anchors.left: parent.left - source: "../icon.png" - } - Text { - x: 25 - text: model.modelData - color: "white" - } - } -} diff --git a/examples/app/qml/window.qml b/examples/app/qml/window.qml deleted file mode 100644 index 2600e26..0000000 --- a/examples/app/qml/window.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Luxoft Sweden AB -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QmlLive tool. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite licenses may use -** this file in accordance with the commercial license agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and The Qt Company. For -** licensing terms and conditions see https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.2 - -Window { - id: window - width: 100 - height: 100 - visible: true - - ListView { - // TODO: Make it work with 'anchors.fill: parent'. Window size seems to - // be propagated too late to the contentItem, giving zero size initially. - width: window.width - height: window.height - - model: ["red", "green", "blue", "black"] - delegate: Rectangle { - width: ListView.view.width - height: 25 - color: model.modelData - Image { - anchors.left: parent.left - source: "../icon.png" - } - Text { - x: 25 - text: model.modelData - color: "white" - } - } - } -} diff --git a/examples/customruntime/customruntime.pro b/examples/customruntime/customruntime.pro new file mode 100644 index 0000000..90920fb --- /dev/null +++ b/examples/customruntime/customruntime.pro @@ -0,0 +1,23 @@ +TEMPLATE = app +TARGET = customruntime +CONFIG += c++11 + +macx*: CONFIG -= app_bundle +QT *= quick + +include(../../src/lib.pri) + +SOURCES += main.cpp + +target.path = $$EXAMPLES_PREFIX/customruntime +INSTALLS += target + +qml.files = qml/*.qml +qml.path = $$target.path/qml +INSTALLS += qml +OTHER_FILES += $$qml.files + +icon.files = icon.png +icon.path = $$target.path +INSTALLS += icon +OTHER_FILES += $$icon.files diff --git a/examples/customruntime/icon.png b/examples/customruntime/icon.png new file mode 100644 index 0000000..1bf2581 Binary files /dev/null and b/examples/customruntime/icon.png differ diff --git a/examples/customruntime/main.cpp b/examples/customruntime/main.cpp new file mode 100644 index 0000000..1050432 --- /dev/null +++ b/examples/customruntime/main.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +//![0] +#include +#include + +// Use QmlLive headers +#include "livenodeengine.h" +#include "remotereceiver.h" + +class MyQmlApplicationEngine : public QQmlApplicationEngine +{ + Q_OBJECT + +public: + MyQmlApplicationEngine(const QString &mainQml); // Perform some setup here + + QString mainQml() const; + QQuickWindow *mainWindow(); + QList warnings() const; + + // ... +}; + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + MyQmlApplicationEngine engine(QStringLiteral("qml/customruntime-window.qml")); + + 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(&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); + + // Advanced use: let it know the initially loaded QML component (do this + // only after registering to receiver!) + node.usePreloadedDocument(engine.mainQml(), engine.mainWindow(), engine.warnings()); +#endif + + return app.exec(); +} +//![0] + +// Keep the snippet simple! +static QString MyQmlApplicationEngine_mainQml; +static QList MyQmlApplicationEngine_warnings; + +MyQmlApplicationEngine::MyQmlApplicationEngine(const QString &mainQml) +{ + // Would be nice to have this in QQmlApplicationEngine + MyQmlApplicationEngine_mainQml = mainQml; + connect(this, &QQmlEngine::warnings, [](const QList &warnings) { + MyQmlApplicationEngine_warnings.append(warnings); + }); + + QStringList colors; + colors.append(QStringLiteral("red")); + colors.append(QStringLiteral("green")); + colors.append(QStringLiteral("blue")); + colors.append(QStringLiteral("black")); + rootContext()->setContextProperty("myColors", colors); + + load(QDir(qApp->applicationDirPath()).absoluteFilePath(mainQml)); +}; + +QString MyQmlApplicationEngine::mainQml() const +{ + return MyQmlApplicationEngine_mainQml; +} + +QQuickWindow *MyQmlApplicationEngine::mainWindow() +{ + if (rootObjects().isEmpty()) + return nullptr; + + return qobject_cast(rootObjects().first()); +} + +QList MyQmlApplicationEngine::warnings() const +{ + return MyQmlApplicationEngine_warnings; +} + +#include "main.moc" diff --git a/examples/customruntime/qml/customruntime-item.qml b/examples/customruntime/qml/customruntime-item.qml new file mode 100644 index 0000000..942a5af --- /dev/null +++ b/examples/customruntime/qml/customruntime-item.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +//! [1] +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + + model: myColors + delegate: Rectangle { + width: ListView.view.width + height: 25 + color: model.modelData + Image { + anchors.left: parent.left + source: "../icon.png" + } + Text { + x: 25 + text: model.modelData + color: "white" + } + } +} +//! [1] diff --git a/examples/customruntime/qml/customruntime-window.qml b/examples/customruntime/qml/customruntime-window.qml new file mode 100644 index 0000000..a722f16 --- /dev/null +++ b/examples/customruntime/qml/customruntime-window.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QmlLive tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +//! [2] +import QtQuick 2.0 +import QtQuick.Window 2.2 + +Window { + id: window + width: 100 + height: 100 + visible: true + + ListView { + // TODO: Make it work with 'anchors.fill: parent'. Window size seems to + // be propagated too late to the contentItem, giving zero size initially. + width: window.width + height: window.height + + model: myColors + delegate: Rectangle { + width: ListView.view.width + height: 25 + color: model.modelData + Image { + anchors.left: parent.left + source: "../icon.png" + } + Text { + x: 25 + text: model.modelData + color: "white" + } + } + } +} +//! [2] diff --git a/examples/examples.pro b/examples/examples.pro index 727afa9..6e28f9a 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS += app \ +SUBDIRS += customruntime \ contentplugin -- cgit v1.2.3