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-24 14:31:42 +0000 |
commit | 3e9bc2cbbcb38970dddca7e6bf1ae5e05e72da2c (patch) | |
tree | ccd8fafde103bd2c6f0fe78dd2c712a94ecc2ce0 | |
parent | 733581bbbd03def6fc3c825854586004ddeae4ce (diff) | |
download | qtwebengine-3e9bc2cbbcb38970dddca7e6bf1ae5e05e72da2c.tar.gz |
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>
16 files changed, 86 insertions, 117 deletions
diff --git a/examples/webenginequick/CMakeLists.txt b/examples/webenginequick/CMakeLists.txt index 14d2f5b51..4b64c2926 100644 --- a/examples/webenginequick/CMakeLists.txt +++ b/examples/webenginequick/CMakeLists.txt @@ -4,7 +4,6 @@ qt_internal_add_example(customdialogs) qt_internal_add_example(customtouchhandle) qt_internal_add_example(lifecycle) -qt_internal_add_example(minimal) qt_internal_add_example(quicknanobrowser) qt_internal_add_example(webengineaction) if(TARGET Qt::QuickControls2) diff --git a/examples/webenginequick/minimal/CMakeLists.txt b/examples/webenginequick/minimal/CMakeLists.txt deleted file mode 100644 index f4715bb97..000000000 --- a/examples/webenginequick/minimal/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(minimal LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginequick/minimal-qml") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineQuick) - -qt_add_executable(webengine-minimal-qml - main.cpp -) - -set_target_properties(webengine-minimal-qml PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(webengine-minimal-qml PUBLIC - Qt::Core - Qt::Gui - Qt::WebEngineQuick -) - -# Resources: -set(qml_resource_files - "main.qml" -) - -qt_add_resources(webengine-minimal-qml "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) - -install(TARGETS webengine-minimal-qml - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/webenginequick/minimal/doc/src/minimal.qdoc b/examples/webenginequick/minimal/doc/src/minimal.qdoc deleted file mode 100644 index aed74a7f5..000000000 --- a/examples/webenginequick/minimal/doc/src/minimal.qdoc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example webenginequick/minimal - \title WebEngine Qt Quick Minimal Example - \ingroup webengine-examples - \brief Displays a web page using the Qt Quick integration of \QWE. - - \image minimal-example.png - - \e {WebEngine Qt Quick Minimal Example} demonstrates how to use the - \l{WebEngineView} item to render a web page. It shows the minimum amount of - code needed to load and display an HTML page, and can be used as a basis for - further experimentation. - - \include examples-run.qdocinc - - \section1 C++ Code - - In \c main.cpp we use only the QGuiApplication and QQmlApplicationEngine - classes. We also include \c qtwebengineglobal.h to be able to use - \l{QtWebEngineQuick::initialize}. - - \quotefromfile webenginequick/minimal/main.cpp - \skipto #include - \printto main - - In the \c main function we first set the - \l{QCoreApplication::organizationName} property. This affects the locations - where \QWE stores persistent and cached data (see also - \l{WebEngineProfile::cachePath} and - \l{WebEngineProfile::persistentStoragePath}). - - Next, we call \l{QtWebEngineQuick::initialize}, which makes sure that OpenGL - contexts can be shared between the main process and the dedicated renderer - process (\c QtWebEngineProcess). This method needs to be called before - any OpenGL context is created. - - Then we create a QQmlApplicationEngine, and tell it to load \c main.qml - from the \l{The Qt Resource System}{Qt Resource System}. - - Finally, QGuiApplication::exec() launches the main event loop. - - \printuntil } - - \section1 QML Code - - In \c main.qml we create the top level window, set a sensible default size - and make it visible. The window will be filled by a WebEngineView item - loading the \l{Qt Homepage}. - - \quotefromfile webenginequick/minimal/main.qml - \skipto import - \printuntil } - \printline } - - \section1 Requirements - - The example requires a working internet connection to render the - \l{Qt Homepage}. - An optional system proxy should be picked up automatically. -*/ diff --git a/examples/webenginequick/webenginequick.pro b/examples/webenginequick/webenginequick.pro index edf4315a0..6a0a858d6 100644 --- a/examples/webenginequick/webenginequick.pro +++ b/examples/webenginequick/webenginequick.pro @@ -3,7 +3,6 @@ TEMPLATE=subdirs SUBDIRS += \ customdialogs \ customtouchhandle \ - minimal \ quicknanobrowser \ webengineaction diff --git a/src/core/doc/src/qtwebengine-overview.qdoc b/src/core/doc/src/qtwebengine-overview.qdoc index 2e1272404..b1e8ee3da 100644 --- a/src/core/doc/src/qtwebengine-overview.qdoc +++ b/src/core/doc/src/qtwebengine-overview.qdoc @@ -162,7 +162,7 @@ The following sample QML application loads a web page using the \l{WebEngineView::}{url} property: - \quotefromfile webenginequick/minimal/main.qml + \quotefromfile minimal/main.qml \skipto import \printuntil /^\}/ 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 8848b03e8..5413d70fb 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 /^\}/ diff --git a/tests/manual/examples/CMakeLists.txt b/tests/manual/examples/CMakeLists.txt index 6e0b301ad..6c9b56c43 100644 --- a/tests/manual/examples/CMakeLists.txt +++ b/tests/manual/examples/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(widgets) +add_subdirectory(quick) diff --git a/tests/manual/examples/quick/CMakeLists.txt b/tests/manual/examples/quick/CMakeLists.txt new file mode 100644 index 000000000..d853ba634 --- /dev/null +++ b/tests/manual/examples/quick/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(minimal) diff --git a/tests/manual/examples/quick/minimal/CMakeLists.txt b/tests/manual/examples/quick/minimal/CMakeLists.txt new file mode 100644 index 000000000..39aaa1ea3 --- /dev/null +++ b/tests/manual/examples/quick/minimal/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(minimal LANGUAGES CXX) + find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineQuick) +endif() + +qt_internal_add_manual_test(webengine-minimal-qml + SOURCES + main.cpp +) + +set_target_properties(webengine-minimal-qml PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(webengine-minimal-qml PUBLIC + Qt::Core + Qt::Gui + Qt::WebEngineQuick +) + +# Resources: +set(qml_resource_files + "main.qml" +) + +qt_add_resources(webengine-minimal-qml "qml" + PREFIX + "/" + FILES + ${qml_resource_files} +) diff --git a/examples/webenginequick/minimal/main.cpp b/tests/manual/examples/quick/minimal/main.cpp index 47b3e146a..16466ae06 100644 --- a/examples/webenginequick/minimal/main.cpp +++ b/tests/manual/examples/quick/minimal/main.cpp @@ -17,4 +17,3 @@ int main(int argc, char *argv[]) return app.exec(); } - diff --git a/examples/webenginequick/minimal/main.qml b/tests/manual/examples/quick/minimal/main.qml index a8733a8c8..a8733a8c8 100644 --- a/examples/webenginequick/minimal/main.qml +++ b/tests/manual/examples/quick/minimal/main.qml diff --git a/examples/webenginequick/minimal/minimal.pro b/tests/manual/examples/quick/minimal/minimal.pro index acca6477c..acca6477c 100644 --- a/examples/webenginequick/minimal/minimal.pro +++ b/tests/manual/examples/quick/minimal/minimal.pro diff --git a/examples/webenginequick/minimal/qml.qrc b/tests/manual/examples/quick/minimal/qml.qrc index 0ff3892d9..0ff3892d9 100644 --- a/examples/webenginequick/minimal/qml.qrc +++ b/tests/manual/examples/quick/minimal/qml.qrc |