diff options
author | Michal Klocek <michal.klocek@qt.io> | 2023-03-17 10:34:53 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-22 12:48:41 +0000 |
commit | 7d9805df3a471e7172bf72ff1bc08c63ccfd67fa (patch) | |
tree | fee4dca1f5f8991c2b1d5736da38ac072ee3cbad /src/webenginequick/doc | |
parent | 37b04eeb90063b9845d4b6154fa3bc7e36ebdf0c (diff) |
Move quick minimal example to manual tests
Task-number: QTBUG-108751
Change-Id: I0998c46f051908855e0406e5fc7c0a422dc3eef0
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit ed76eef004dbac15f4740d33d06d2b271bf770d4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/webenginequick/doc')
4 files changed, 47 insertions, 2 deletions
diff --git a/src/webenginequick/doc/snippets/minimal/main.cpp b/src/webenginequick/doc/snippets/minimal/main.cpp new file mode 100644 index 000000000..e17493a36 --- /dev/null +++ b/src/webenginequick/doc/snippets/minimal/main.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [Minimal Example] +#include <QGuiApplication> +#include <QQmlApplicationEngine> +#include <QtWebEngineQuick/qtwebenginequickglobal.h> + +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + QtWebEngineQuick::initialize(); + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + return app.exec(); +} +//! [Minimal Example] diff --git a/src/webenginequick/doc/snippets/minimal/main.qml b/src/webenginequick/doc/snippets/minimal/main.qml new file mode 100644 index 000000000..87a8757df --- /dev/null +++ b/src/webenginequick/doc/snippets/minimal/main.qml @@ -0,0 +1,18 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [Minimal Example] +import QtQuick +import QtQuick.Window +import QtWebEngine + +Window { + width: 1024 + height: 750 + visible: true + WebEngineView { + anchors.fill: parent + url: "https://www.qt.io" + } +} +//! [Minimal Example] diff --git a/src/webenginequick/doc/src/qtwebengine-qmlmodule.qdoc b/src/webenginequick/doc/src/qtwebengine-qmlmodule.qdoc index 19348508c..ecf3a4a6e 100644 --- a/src/webenginequick/doc/src/qtwebengine-qmlmodule.qdoc +++ b/src/webenginequick/doc/src/qtwebengine-qmlmodule.qdoc @@ -17,4 +17,13 @@ in the Qt6 package and \c target_link_libraries() to link against the module: \snippet qtwebengine_build_snippet.qdoc 2 + + The minimal amount of code needed to load and display an HTML page using the QML engine + requires a proper initialization: + + \snippet minimal/main.cpp Minimal Example + + Where the content of main.qml is simply: + + \snippet minimal/main.qml Minimal Example */ diff --git a/src/webenginequick/doc/src/webengineview_lgpl.qdoc b/src/webenginequick/doc/src/webengineview_lgpl.qdoc index b501b3001..56dfea71b 100644 --- a/src/webenginequick/doc/src/webengineview_lgpl.qdoc +++ b/src/webenginequick/doc/src/webengineview_lgpl.qdoc @@ -24,7 +24,7 @@ \l QtWebEngineQuick::initialize in the application main source file, as illustrated by the following code snippet: - \quotefromfile webenginequick/minimal/main.cpp + \quotefromfile minimal/main.cpp \skipto main \printuntil } @@ -39,7 +39,7 @@ The following sample QML application loads a web page using the \c url property: - \quotefromfile webenginequick/minimal/main.qml + \quotefromfile minimal/main.qml \skipto import \printuntil /^\}/ |