diff options
-rw-r--r-- | examples/qml/xmlhttprequest/CMakeLists.txt | 59 | ||||
-rw-r--r-- | examples/qml/xmlhttprequest/Get.qml | 64 | ||||
-rw-r--r-- | examples/qml/xmlhttprequest/GetForm.ui.qml | 83 | ||||
-rw-r--r-- | examples/qml/xmlhttprequest/main.cpp | 28 | ||||
-rw-r--r-- | examples/qml/xmlhttprequest/xmlhttprequest.pro | 5 | ||||
-rw-r--r-- | examples/qml/xmlhttprequest/xmlhttprequest.qml | 29 | ||||
-rw-r--r-- | examples/qml/xmlhttprequest/xmlhttprequest.qrc | 6 |
7 files changed, 61 insertions, 213 deletions
diff --git a/examples/qml/xmlhttprequest/CMakeLists.txt b/examples/qml/xmlhttprequest/CMakeLists.txt index 71a33e7264..a3fe890634 100644 --- a/examples/qml/xmlhttprequest/CMakeLists.txt +++ b/examples/qml/xmlhttprequest/CMakeLists.txt @@ -7,7 +7,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) if(NOT DEFINED INSTALL_EXAMPLESDIR) set(INSTALL_EXAMPLESDIR "examples") @@ -15,64 +14,32 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/xmlhttprequest") -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Qml) +find_package(Qt6 COMPONENTS Core Gui Quick Qml) -qt_add_executable(xmlhttprequest +qt_add_executable(xmlhttprequestexample + WIN32 + MACOSX_BUNDLE main.cpp ) -set_target_properties(xmlhttprequest PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(xmlhttprequest PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) -set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qml) -qt_add_qml_module(xmlhttprequest +qt_add_qml_module(xmlhttprequestexample URI xmlhttprequest VERSION 1.0 QML_FILES - Get.qml - GetForm.ui.qml - methods.js - xmlhttprequest.qml + "methods.js" + "xmlhttprequest.qml" RESOURCES data.xml - RESOURCE_PREFIX /qml ) -# These files live outside of the QML module, so add them separately -set(quick_shared_resource_files - "../../quick/shared/Button.qml" - "../../quick/shared/CheckBox.qml" - "../../quick/shared/Label.qml" - "../../quick/shared/LauncherList.qml" - "../../quick/shared/SimpleLauncherDelegate.qml" - "../../quick/shared/Slider.qml" - "../../quick/shared/TextField.qml" - "../../quick/shared/images/back.png" - "../../quick/shared/images/checkmark.png" - "../../quick/shared/images/next.png" - "../../quick/shared/images/slider_handle.png" -) - -qt6_add_resources(xmlhttprequest "quick_shared" - PREFIX - "/quick/shared" - BASE - "../../quick/shared" - FILES - ${quick_shared_resource_files} +target_link_libraries(xmlhttprequestexample PUBLIC + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick ) -install(TARGETS xmlhttprequest +install(TARGETS xmlhttprequestexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/qml/xmlhttprequest/Get.qml b/examples/qml/xmlhttprequest/Get.qml deleted file mode 100644 index 96cec2a99d..0000000000 --- a/examples/qml/xmlhttprequest/Get.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "methods.js" as Utils - -GetForm -{ - anchors.fill: parent - - mouseArea.onClicked: Utils.makeRequest() - - button.border.width: mouseArea.pressed ? 2 : 1 - text.text: "Request data.xml" - -} diff --git a/examples/qml/xmlhttprequest/GetForm.ui.qml b/examples/qml/xmlhttprequest/GetForm.ui.qml deleted file mode 100644 index 284299ef35..0000000000 --- a/examples/qml/xmlhttprequest/GetForm.ui.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - - -Rectangle { - id:rect - width: 350 - height: 400 - - property alias button: button - property alias text: buttonText - property alias mouseArea: mouseArea - property alias msg: ttext - - Text { id: ttext; anchors.fill: parent; anchors.margins: 10 } - - Rectangle { - id: button - anchors.horizontalCenter: parent.horizontalCenter; - anchors.bottom: parent.bottom - anchors.margins: 10 - width: buttonText.width + 10 - height: buttonText.height + 10 - radius : 5; antialiasing: true - - Text { id: buttonText; anchors.centerIn: parent } - - MouseArea { - id: mouseArea - anchors.fill: parent - } - } -} - diff --git a/examples/qml/xmlhttprequest/main.cpp b/examples/qml/xmlhttprequest/main.cpp index 02be6d2196..cef60a5e6f 100644 --- a/examples/qml/xmlhttprequest/main.cpp +++ b/examples/qml/xmlhttprequest/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -47,5 +47,27 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "../../quick/shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(qml/xmlhttprequest/xmlhttprequest) + +#include <QDir> +#include <QGuiApplication> +#include <QQmlFileSelector> +#include <QQuickView> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + app.setOrganizationName("QtProject"); + app.setOrganizationDomain("qt-project.org"); + app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName()); + QQuickView view; + + qputenv("QML_XHR_ALLOW_FILE_READ", QByteArray("1")); + + view.connect(view.engine(), &QQmlEngine::quit, &app, &QCoreApplication::quit); + view.setSource(QUrl("qrc:///xmlhttprequest/xmlhttprequest.qml")); + if (view.status() == QQuickView::Error) + return -1; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.show(); + return app.exec(); +} diff --git a/examples/qml/xmlhttprequest/xmlhttprequest.pro b/examples/qml/xmlhttprequest/xmlhttprequest.pro index 3b78db0252..6d572fff59 100644 --- a/examples/qml/xmlhttprequest/xmlhttprequest.pro +++ b/examples/qml/xmlhttprequest/xmlhttprequest.pro @@ -3,8 +3,7 @@ TEMPLATE = app QT += quick qml SOURCES += main.cpp RESOURCES += \ - xmlhttprequest.qrc \ - ../../quick/shared/quick_shared.qrc + xmlhttprequest.qrc EXAMPLE_FILES = \ data.xml @@ -13,6 +12,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qml/xmlhttprequest INSTALLS += target DISTFILES += \ - Get.qml \ - GetForm.ui.qml \ methods.js diff --git a/examples/qml/xmlhttprequest/xmlhttprequest.qml b/examples/qml/xmlhttprequest/xmlhttprequest.qml index e6c7b10e16..31aa1824e9 100644 --- a/examples/qml/xmlhttprequest/xmlhttprequest.qml +++ b/examples/qml/xmlhttprequest/xmlhttprequest.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,17 +48,28 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import "../../quick/shared" as Examples +import QtQuick +import QtQuick.Controls +import "methods.js" as Utils + Item { height: 480 width: 320 - Examples.LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("Get data", "Send get request and show received header and body", Qt.resolvedUrl("Get.qml")); - } + + property alias msg: ttext + + Label { id: ttext; anchors.fill: parent; anchors.margins: 10 } + + Button { + id: button + anchors.horizontalCenter: parent.horizontalCenter; + anchors.bottom: parent.bottom + anchors.margins: 10 + antialiasing: true + + text: qsTr("Request data.xml") + + onClicked: Utils.makeRequest() } } diff --git a/examples/qml/xmlhttprequest/xmlhttprequest.qrc b/examples/qml/xmlhttprequest/xmlhttprequest.qrc index 2e5dae4bb8..75c0edca8a 100644 --- a/examples/qml/xmlhttprequest/xmlhttprequest.qrc +++ b/examples/qml/xmlhttprequest/xmlhttprequest.qrc @@ -1,9 +1,7 @@ <RCC> - <qresource prefix="/qml/xmlhttprequest"> + <qresource prefix="/xmlhttprequest"> <file>xmlhttprequest.qml</file> - <file>data.xml</file> <file>methods.js</file> - <file>Get.qml</file> - <file>GetForm.ui.qml</file> + <file>data.xml</file> </qresource> </RCC> |