diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-30 15:46:39 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-31 11:26:10 +0200 |
commit | a3ea7a99381748c457336bfa8b9373070ebfa3ee (patch) | |
tree | ffd1767dcf3eafe8766185aad252058b451867b7 /examples/quick/tutorials/samegame/samegame1 | |
parent | ea5911adbb6527d679338cd39dd1c3f843c0f7ce (diff) |
Fix samegame example to use QML modules
In this case it really makes no sense to use a shared directory because
we want to show the progressive changes between the different versions.
It's actually important to note that we're adding the pictures one by
one. Therefore, the shared directory is dissolved and the pictures added
duplicated into the respective versions of samegame.
Furthermore, moving the code into a "content" directory is a bad idea
because it complicates the import logic. We don't want to make the
"content" directory its own QML module. We might move samegame.qml into
the "content" directory, too, and apply some path wrangling to make it
work, but it's really not worth it here.
Pick-to: 6.2
Change-Id: Ifc45f48832596377c21bc6ef55e918ef487bc94e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'examples/quick/tutorials/samegame/samegame1')
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/Block.qml | 2 | ||||
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/CMakeLists.txt | 51 | ||||
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/main.cpp | 2 | ||||
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/pics/background.jpg | bin | 0 -> 36473 bytes | |||
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/pics/redStone.png | bin | 0 -> 2902 bytes | |||
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/samegame.qml | 2 | ||||
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/samegame1.pro | 5 | ||||
-rw-r--r-- | examples/quick/tutorials/samegame/samegame1/samegame1.qrc | 4 |
8 files changed, 58 insertions, 8 deletions
diff --git a/examples/quick/tutorials/samegame/samegame1/Block.qml b/examples/quick/tutorials/samegame/samegame1/Block.qml index eac8e93810..157a3aa0c9 100644 --- a/examples/quick/tutorials/samegame/samegame1/Block.qml +++ b/examples/quick/tutorials/samegame/samegame1/Block.qml @@ -57,7 +57,7 @@ Item { Image { id: img anchors.fill: parent - source: "../shared/pics/redStone.png" + source: "pics/redStone.png" } } //![0] diff --git a/examples/quick/tutorials/samegame/samegame1/CMakeLists.txt b/examples/quick/tutorials/samegame/samegame1/CMakeLists.txt new file mode 100644 index 0000000000..ad791d77b5 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame1/CMakeLists.txt @@ -0,0 +1,51 @@ +cmake_minimum_required(VERSION 3.16) +project(samegame1 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/tutorials/samegame/samegame1") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Quick) +find_package(Qt6 COMPONENTS Qml) + +qt_add_executable(samegame1 + main.cpp +) +set_target_properties(samegame1 PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +qt_add_qml_module(samegame1 + URI samegame + VERSION 1.0 + QML_FILES + "Block.qml" + "Button.qml" + "samegame.qml" + RESOURCES + "pics/background.jpg" + "pics/redStone.png" +) + +target_link_libraries(samegame1 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +install(TARGETS samegame1 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quick/tutorials/samegame/samegame1/main.cpp b/examples/quick/tutorials/samegame/samegame1/main.cpp index 7589b92906..f76b5d8940 100644 --- a/examples/quick/tutorials/samegame/samegame1/main.cpp +++ b/examples/quick/tutorials/samegame/samegame1/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(samegame) +DECLARATIVE_EXAMPLE_MAIN(samegame/samegame) diff --git a/examples/quick/tutorials/samegame/samegame1/pics/background.jpg b/examples/quick/tutorials/samegame/samegame1/pics/background.jpg Binary files differnew file mode 100644 index 0000000000..903d395c8d --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame1/pics/background.jpg diff --git a/examples/quick/tutorials/samegame/samegame1/pics/redStone.png b/examples/quick/tutorials/samegame/samegame1/pics/redStone.png Binary files differnew file mode 100644 index 0000000000..36b09a2686 --- /dev/null +++ b/examples/quick/tutorials/samegame/samegame1/pics/redStone.png diff --git a/examples/quick/tutorials/samegame/samegame1/samegame.qml b/examples/quick/tutorials/samegame/samegame1/samegame.qml index 68a1921da7..9eea87fc9c 100644 --- a/examples/quick/tutorials/samegame/samegame1/samegame.qml +++ b/examples/quick/tutorials/samegame/samegame1/samegame.qml @@ -65,7 +65,7 @@ Rectangle { Image { id: background anchors.fill: parent - source: "../shared/pics/background.jpg" + source: "pics/background.jpg" fillMode: Image.PreserveAspectCrop } } diff --git a/examples/quick/tutorials/samegame/samegame1/samegame1.pro b/examples/quick/tutorials/samegame/samegame1/samegame1.pro index 9f316b6868..d523857d64 100644 --- a/examples/quick/tutorials/samegame/samegame1/samegame1.pro +++ b/examples/quick/tutorials/samegame/samegame1/samegame1.pro @@ -2,10 +2,7 @@ TEMPLATE = app QT += quick qml SOURCES += main.cpp - -RESOURCES += \ - samegame1.qrc \ - ../shared/pics/shared.qrc +RESOURCES += samegame1.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quick/tutorials/samegame/samegame1 INSTALLS += target diff --git a/examples/quick/tutorials/samegame/samegame1/samegame1.qrc b/examples/quick/tutorials/samegame/samegame1/samegame1.qrc index 866cf899bf..1f061d606f 100644 --- a/examples/quick/tutorials/samegame/samegame1/samegame1.qrc +++ b/examples/quick/tutorials/samegame/samegame1/samegame1.qrc @@ -1,7 +1,9 @@ <RCC> - <qresource prefix="/"> + <qresource prefix="/samegame"> <file>Button.qml</file> <file>Block.qml</file> <file>samegame.qml</file> + <file>pics/background.jpg</file> + <file>pics/redStone.png</file> </qresource> </RCC> |