diff options
Diffstat (limited to 'src/corelib/doc/snippets')
-rw-r--r-- | src/corelib/doc/snippets/resource-system/CMakeLists.txt | 31 | ||||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/application.pro | 25 | ||||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/application.qrc | 18 | ||||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/images/copy.png | bin | 0 -> 67 bytes | |||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/images/cut.png | bin | 0 -> 67 bytes | |||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/images/new.png | bin | 0 -> 67 bytes | |||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/images/open.png | bin | 0 -> 67 bytes | |||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/images/paste.png | bin | 0 -> 67 bytes | |||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/images/save.png | bin | 0 -> 67 bytes | |||
-rw-r--r-- | src/corelib/doc/snippets/resource-system/main.cpp | 75 |
10 files changed, 131 insertions, 18 deletions
diff --git a/src/corelib/doc/snippets/resource-system/CMakeLists.txt b/src/corelib/doc/snippets/resource-system/CMakeLists.txt index 29727bd958..a488d869e6 100644 --- a/src/corelib/doc/snippets/resource-system/CMakeLists.txt +++ b/src/corelib/doc/snippets/resource-system/CMakeLists.txt @@ -1,23 +1,38 @@ project(my_app) cmake_minimum_required(VERSION 3.16) -find_package(Qt6 REQUIRED COMPONENTS Widgets) +find_package(Qt6 COMPONENTS Widgets Qml REQUIRED) #! [AUTORCC] set(CMAKE_AUTORCC ON) qt_add_executable(my_app application.qrc - mainwindow.cpp) + main.cpp +) #! [AUTORCC] #! [qt_add_resources] qt_add_resources(my_app "app_images" PREFIX "/" FILES - "images/copy.png" - "images/cut.png" - "images/new.png" - "images/open.png" - "images/paste.png" - "images/save.png") + images/copy.png + images/cut.png + images/new.png + images/open.png + images/paste.png + images/save.png +) #! [qt_add_resources] + +#! [qt_add_big_resources] +qt_add_big_resources(SOURCES application.qrc) +target_sources(my_app PRIVATE ${SOURCES}) +#! [qt_add_big_resources] + +#! [qt_add_binary_resources] +qt_add_binary_resources(resources application.qrc DESTINATION application.rcc) +add_dependencies(my_app resources) +#! [qt_add_binary_resources] + +target_link_libraries(my_app + PRIVATE Qt6::Qml Qt6::Widgets) diff --git a/src/corelib/doc/snippets/resource-system/application.pro b/src/corelib/doc/snippets/resource-system/application.pro index ecf4ce1093..4b1f1d7635 100644 --- a/src/corelib/doc/snippets/resource-system/application.pro +++ b/src/corelib/doc/snippets/resource-system/application.pro @@ -1,3 +1,26 @@ +TEMPLATE = app + +QT += qml widgets + #! [0] -RESOURCES = application.qrc +RESOURCES = application.qrc #! [0] + +#! [1] +resources.files = \ + images/copy.png \ + images/cut.png \ + images/new.png \ + images/open.png \ + images/paste.png \ + images/save.png +resources.prefix = / + +RESOURCES = resources +#! [1] + +#! [2] +CONFIG += resources_big +#! [2] + +SOURCES += main.cpp diff --git a/src/corelib/doc/snippets/resource-system/application.qrc b/src/corelib/doc/snippets/resource-system/application.qrc index 0a776fab4d..3eef379234 100644 --- a/src/corelib/doc/snippets/resource-system/application.qrc +++ b/src/corelib/doc/snippets/resource-system/application.qrc @@ -1,10 +1,10 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>images/copy.png</file> - <file>images/cut.png</file> - <file>images/new.png</file> - <file>images/open.png</file> - <file>images/paste.png</file> - <file>images/save.png</file> -</qresource> +<RCC> + <qresource prefix="/"> + <file>images/copy.png</file> + <file>images/cut.png</file> + <file>images/new.png</file> + <file>images/open.png</file> + <file>images/paste.png</file> + <file>images/save.png</file> + </qresource> </RCC> diff --git a/src/corelib/doc/snippets/resource-system/images/copy.png b/src/corelib/doc/snippets/resource-system/images/copy.png Binary files differnew file mode 100644 index 0000000000..91a99b94e2 --- /dev/null +++ b/src/corelib/doc/snippets/resource-system/images/copy.png diff --git a/src/corelib/doc/snippets/resource-system/images/cut.png b/src/corelib/doc/snippets/resource-system/images/cut.png Binary files differnew file mode 100644 index 0000000000..91a99b94e2 --- /dev/null +++ b/src/corelib/doc/snippets/resource-system/images/cut.png diff --git a/src/corelib/doc/snippets/resource-system/images/new.png b/src/corelib/doc/snippets/resource-system/images/new.png Binary files differnew file mode 100644 index 0000000000..91a99b94e2 --- /dev/null +++ b/src/corelib/doc/snippets/resource-system/images/new.png diff --git a/src/corelib/doc/snippets/resource-system/images/open.png b/src/corelib/doc/snippets/resource-system/images/open.png Binary files differnew file mode 100644 index 0000000000..91a99b94e2 --- /dev/null +++ b/src/corelib/doc/snippets/resource-system/images/open.png diff --git a/src/corelib/doc/snippets/resource-system/images/paste.png b/src/corelib/doc/snippets/resource-system/images/paste.png Binary files differnew file mode 100644 index 0000000000..91a99b94e2 --- /dev/null +++ b/src/corelib/doc/snippets/resource-system/images/paste.png diff --git a/src/corelib/doc/snippets/resource-system/images/save.png b/src/corelib/doc/snippets/resource-system/images/save.png Binary files differnew file mode 100644 index 0000000000..91a99b94e2 --- /dev/null +++ b/src/corelib/doc/snippets/resource-system/images/save.png diff --git a/src/corelib/doc/snippets/resource-system/main.cpp b/src/corelib/doc/snippets/resource-system/main.cpp new file mode 100644 index 0000000000..892f29d01d --- /dev/null +++ b/src/corelib/doc/snippets/resource-system/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation 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$ +** +****************************************************************************/ + +#include <QQmlApplicationEngine> +#include <QAction> +#include <QIcon> +#include <QApplication> +#include <QWidget> + +class DummyWidget : public QWidget { + Q_OBJECT + + QAction *cutAct; + + DummyWidget() { + //! [QAction] + cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); + //! [QAction] + } +}; + +int main() +{ +//! [url] + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/myapp/main.qml")); +//! [url] +} |