Fix localstorage example to use a QML module

Removing the directory 'localstorage' that is inside the top-level
'localstorage' directory, and moving the content one level up in the
file hierarchy.

Pick-to: 6.2
Change-Id: I97cf1ff92be9860d9a92bce66c88af927618e2b0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Oliver Eftevaag 2021-09-01 15:40:28 +02:00
parent 5e6777be1d
commit b0e567e7e3
11 changed files with 56 additions and 72 deletions

View File

@ -1,3 +1,47 @@
# Generated from localstorage.pro.
qt_internal_add_example(localstorage)
cmake_minimum_required(VERSION 3.16)
project(localstorage 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/localstorage")
find_package(Qt6 COMPONENTS Core Gui Quick Qml)
qt_add_executable(localstorageexample
WIN32
MACOSX_BUNDLE
main.cpp
)
qt_add_qml_module(localstorageexample
URI localstorage
VERSION 1.0
QML_FILES
"Database.js"
"Header.qml"
"MyDelegate.qml"
"MyModel.qml"
"localstorage.qml"
)
target_link_libraries(localstorageexample PUBLIC
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
)
install(TARGETS localstorageexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)

View File

@ -1,2 +1,9 @@
TEMPLATE = subdirs
SUBDIRS += localstorage
TEMPLATE = app
QT += quick qml
SOURCES += main.cpp
RESOURCES += \
localstorage.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/quick/localstorage
INSTALLS += target

View File

@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/">
<qresource prefix="/localstorage">
<file>Header.qml</file>
<file>Database.js</file>
<file>MyModel.qml</file>

View File

@ -1,58 +0,0 @@
# Generated from localstorage.pro.
cmake_minimum_required(VERSION 3.16)
project(localstorage LANGUAGES CXX)
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")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/localstorage/localstorage")
find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Quick)
find_package(Qt6 COMPONENTS Qml)
qt_add_executable(localstorage
main.cpp
)
set_target_properties(localstorage PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
target_link_libraries(localstorage PUBLIC
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
)
# Resources:
set(localstorage_resource_files
"Database.js"
"Header.qml"
"MyDelegate.qml"
"MyModel.qml"
"localstorage.qml"
)
qt6_add_resources(localstorage "localstorage"
PREFIX
"/"
FILES
${localstorage_resource_files}
)
install(TARGETS localstorage
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)

View File

@ -1,9 +0,0 @@
TEMPLATE = app
QT += quick qml
SOURCES += main.cpp
RESOURCES += \
localstorage.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/quick/localstorage/localstorage
INSTALLS += target

View File

@ -55,7 +55,7 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/localstorage.qml")));
engine.load(QUrl(QStringLiteral("qrc:/localstorage/localstorage.qml")));
return app.exec();
}