Fix dialcontrol example to use a QML module

Also move the QML files out of the "content" subdirectory in order to
avoid the directory import.

Pick-to: 6.2
Change-Id: I84a1f5ef1a45e5098ec3213c6fbce06346f3606a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Ulf Hermann 2021-08-31 13:32:26 +02:00
parent 66c011c558
commit 2dfb912058
11 changed files with 26 additions and 32 deletions

View File

@ -20,41 +20,36 @@ find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Quick) find_package(Qt6 COMPONENTS Quick)
find_package(Qt6 COMPONENTS Qml) find_package(Qt6 COMPONENTS Qml)
qt_add_executable(dialcontrol qt_add_executable(dialcontrolexample
main.cpp main.cpp
) )
set_target_properties(dialcontrol PROPERTIES set_target_properties(dialcontrolexample PROPERTIES
WIN32_EXECUTABLE TRUE WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE MACOSX_BUNDLE TRUE
) )
target_link_libraries(dialcontrol PUBLIC target_link_libraries(dialcontrolexample PUBLIC
Qt::Core Qt::Core
Qt::Gui Qt::Gui
Qt::Qml Qt::Qml
Qt::Quick Qt::Quick
) )
qt_add_qml_module(dialcontrolexample
# Resources: URI dialcontrol
set(dialcontrol_resource_files VERSION 1.0
"content/Dial.qml" QML_FILES
"content/QuitButton.qml" "Dial.qml"
"content/background.png" "QuitButton.qml"
"content/needle.png"
"content/needle_shadow.png"
"content/overlay.png"
"content/quit.png"
"dialcontrol.qml" "dialcontrol.qml"
RESOURCES
"background.png"
"needle.png"
"needle_shadow.png"
"overlay.png"
"quit.png"
) )
qt6_add_resources(dialcontrol "dialcontrol" install(TARGETS dialcontrolexample
PREFIX
"/"
FILES
${dialcontrol_resource_files}
)
install(TARGETS dialcontrol
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -51,7 +51,6 @@
//! [imports] //! [imports]
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Window 2.1 import QtQuick.Window 2.1
import "content"
//! [imports] //! [imports]
//! [0] //! [0]

View File

@ -1,12 +1,12 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/dialcontrol">
<file>Dial.qml</file>
<file>QuitButton.qml</file>
<file>background.png</file>
<file>dialcontrol.qml</file> <file>dialcontrol.qml</file>
<file>content/background.png</file> <file>needle.png</file>
<file>content/Dial.qml</file> <file>needle_shadow.png</file>
<file>content/needle_shadow.png</file> <file>overlay.png</file>
<file>content/needle.png</file> <file>quit.png</file>
<file>content/overlay.png</file>
<file>content/quit.png</file>
<file>content/QuitButton.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -48,4 +48,4 @@
** **
****************************************************************************/ ****************************************************************************/
#include "../../shared/shared.h" #include "../../shared/shared.h"
DECLARATIVE_EXAMPLE_MAIN(dialcontrol) DECLARATIVE_EXAMPLE_MAIN(dialcontrol/dialcontrol)

View File

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 342 B

View File

Before

Width:  |  Height:  |  Size: 632 B

After

Width:  |  Height:  |  Size: 632 B

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 583 B