diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-11-08 12:02:30 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-11-09 18:55:15 +0100 |
commit | 5e8e12b342657b9dabffd86e7f2b0d1ae194bd54 (patch) | |
tree | 114749d8464a72acbbda15fd37a1f9a1a7d8aff8 /examples | |
parent | de6c7aa7340b96e8d1d480011dc11a1a094074e2 (diff) |
Fix CMakeLists.txts of chattutorial
- Run pro2cmake.py on each .pro and did some manual adjustments.
- Rename directories to simplify resource paths, URIs, etc.
- Rename executables to ensure they're distinguishable from other
targets in Creator's locator.
- Duplicate images into each example due to issues with resources.
- Now that we use qt_add_qml_module, the qtquickcontrols2.conf
file will no longer be at the resource root, so specify it
separately with qt6_add_resources.
- Update qmake files.
- Fix documentation.
Task-number: QTBUG-98130
Pick-to: 6.2
Change-Id: I210ef2cbcd45dd7f4df881332174bff1b18c5be7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples')
110 files changed, 517 insertions, 524 deletions
diff --git a/examples/quickcontrols2/chattutorial/CMakeLists.txt b/examples/quickcontrols2/chattutorial/CMakeLists.txt index 9bfd799492..22546aabec 100644 --- a/examples/quickcontrols2/chattutorial/CMakeLists.txt +++ b/examples/quickcontrols2/chattutorial/CMakeLists.txt @@ -1,10 +1,10 @@ # Generated from chattutorial.pro. -add_subdirectory(chapter1-settingup) -add_subdirectory(chapter2-lists) -add_subdirectory(chapter3-navigation) +add_subdirectory(chapter1) +add_subdirectory(chapter2) +add_subdirectory(chapter3) if (TARGET Qt::Sql) - add_subdirectory(chapter4-models) - add_subdirectory(chapter5-styling) + add_subdirectory(chapter4) + add_subdirectory(chapter5) endif() diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter1-settingup/CMakeLists.txt deleted file mode 100644 index 00cf9f6025..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# Generated from chapter1-settingup.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter1-settingup 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}/quickcontrols2/chattutorial/chapter1-settingup") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) - -qt_add_executable(chapter1-settingup - main.cpp -) -set_target_properties(chapter1-settingup PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter1-settingup PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - - -# Resources: -set(qml_resource_files - "main.qml" -) - -qt6_add_resources(chapter1-settingup "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) - -install(TARGETS chapter1-settingup - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup.pro b/examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup.pro deleted file mode 100644 index 6b7e71082c..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app - -QT += qml quick -CONFIG += c++11 - -SOURCES += main.cpp - -RESOURCES += qml.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter1-settingup -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/qml.qrc b/examples/quickcontrols2/chattutorial/chapter1-settingup/qml.qrc deleted file mode 100644 index 0ff3892d9c..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/qml.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - </qresource> -</RCC> - diff --git a/examples/quickcontrols2/chattutorial/chapter1/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter1/CMakeLists.txt new file mode 100644 index 0000000000..4b8770a83d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter1/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter1 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter1") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick) + +qt_add_executable(chattutorial-chapter1 WIN32 MACOSX_BUNDLE + main.cpp +) +target_link_libraries(chattutorial-chapter1 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +qt_add_qml_module(chattutorial-chapter1 + URI chapter1 + VERSION 1.0 + QML_FILES + "main.qml" +) + +qt6_add_resources(chattutorial-chapter1 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter1 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/chapter2-lists.pro b/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro index dff0aac2b1..221bb855f5 100644 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/chapter2-lists.pro +++ b/examples/quickcontrols2/chattutorial/chapter1/chapter1.pro @@ -5,8 +5,9 @@ CONFIG += c++11 SOURCES += main.cpp -RESOURCES += qml.qrc \ - ../shared/shared.qrc +RESOURCES += \ + main.qml \ + qtquickcontrols2.conf -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter2-lists +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter1 INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.cpp b/examples/quickcontrols2/chattutorial/chapter1/main.cpp index ea20c89012..ca175ccf9c 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter1/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter1/main.qml"))); return app.exec(); } diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml b/examples/quickcontrols2/chattutorial/chapter1/main.qml index 3dc93e47d0..3dc93e47d0 100644 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter1/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter1/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter1/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter1/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter2-lists/CMakeLists.txt deleted file mode 100644 index 9bc55dad96..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -# Generated from chapter2-lists.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter2-lists 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}/quickcontrols2/chattutorial/chapter2-lists") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) - -qt_add_executable(chapter2-lists - main.cpp -) -set_target_properties(chapter2-lists PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter2-lists PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - - -# Resources: -set(qml_resource_files - "main.qml" -) - -qt6_add_resources(chapter2-lists "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter2-lists "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter2-lists - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/qml.qrc b/examples/quickcontrols2/chattutorial/chapter2-lists/qml.qrc deleted file mode 100644 index 0ff3892d9c..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/qml.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - </qresource> -</RCC> - diff --git a/examples/quickcontrols2/chattutorial/chapter2/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter2/CMakeLists.txt new file mode 100644 index 0000000000..5c73c212ce --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter2/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter2 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter2") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick) + +qt_add_executable(chattutorial-chapter2 WIN32 MACOSX_BUNDLE + main.cpp +) +target_link_libraries(chattutorial-chapter2 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +qt_add_qml_module(chattutorial-chapter2 + URI chapter2 + VERSION 1.0 + QML_FILES + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter2 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter2 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro b/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro new file mode 100644 index 0000000000..e217934b7e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter2/chapter2.pro @@ -0,0 +1,25 @@ +TEMPLATE = app + +QT += qml quick +CONFIG += c++11 + +SOURCES += main.cpp + +RESOURCES += \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter2 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein.png Binary files differindex 7c44b90b8d..7c44b90b8d 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@2x.png Binary files differindex 6ce9c39b6c..6ce9c39b6c 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@2x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@3x.png Binary files differindex aab6a6a162..aab6a6a162 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@3x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@4x.png Binary files differindex 3611284df4..3611284df4 100644 --- a/examples/quickcontrols2/chattutorial/shared/Albert_Einstein@4x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway.png Binary files differindex 3ac8992fd9..3ac8992fd9 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@2x.png Binary files differindex 122d9f1e53..122d9f1e53 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@2x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@3x.png Binary files differindex 2fe9c2cc1c..2fe9c2cc1c 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@3x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@4x.png Binary files differindex 96fb6788b5..96fb6788b5 100644 --- a/examples/quickcontrols2/chattutorial/shared/Ernest_Hemingway@4x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude.png Binary files differindex 907e38bc61..907e38bc61 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@2x.png Binary files differindex 6837796a83..6837796a83 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@2x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@3x.png Binary files differindex 29af422ad3..29af422ad3 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@3x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@4x.png Binary files differindex bc35eeaa79..bc35eeaa79 100644 --- a/examples/quickcontrols2/chattutorial/shared/Hans_Gude@4x.png +++ b/examples/quickcontrols2/chattutorial/chapter2/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/shared/shared.qrc b/examples/quickcontrols2/chattutorial/chapter2/images/images.qrc index 9eda6aa29c..9eda6aa29c 100644 --- a/examples/quickcontrols2/chattutorial/shared/shared.qrc +++ b/examples/quickcontrols2/chattutorial/chapter2/images/images.qrc diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/main.cpp b/examples/quickcontrols2/chattutorial/chapter2/main.cpp index ea20c89012..55997aa8ad 100644 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter2/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter2/main.qml"))); return app.exec(); } diff --git a/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml b/examples/quickcontrols2/chattutorial/chapter2/main.qml index 66a51d2db2..8a87d41020 100644 --- a/examples/quickcontrols2/chattutorial/chapter2-lists/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter2/main.qml @@ -83,7 +83,7 @@ ApplicationWindow { Image { id: avatar - source: "qrc:/" + modelData.replace(" ", "_") + ".png" + source: "images/" + modelData.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter2/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter2/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter2/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter3-navigation/CMakeLists.txt deleted file mode 100644 index 6c258e709b..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -# Generated from chapter3-navigation.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter3-navigation 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}/quickcontrols2/chattutorial/chapter3-navigation") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) - -qt_add_executable(chapter3-navigation - main.cpp -) -set_target_properties(chapter3-navigation PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter3-navigation PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - - -# Resources: -set(qml_resource_files - "ContactPage.qml" - "ConversationPage.qml" - "main.qml" -) - -qt6_add_resources(chapter3-navigation "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter3-navigation "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter3-navigation - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation.pro b/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation.pro deleted file mode 100644 index 92736a651d..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = app - -QT += qml quick -CONFIG += c++11 - -SOURCES += main.cpp - -RESOURCES += qml.qrc \ - ../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter3-navigation -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/qml.qrc b/examples/quickcontrols2/chattutorial/chapter3-navigation/qml.qrc deleted file mode 100644 index a72e1b7134..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/qml.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - <file>ContactPage.qml</file> - <file>ConversationPage.qml</file> - </qresource> -</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter3/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter3/CMakeLists.txt new file mode 100644 index 0000000000..e835d38ac9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter3 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter3") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick) + +qt_add_executable(chattutorial-chapter3 WIN32 MACOSX_BUNDLE + main.cpp +) +target_link_libraries(chattutorial-chapter3 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + +# Resources: +qt_add_qml_module(chattutorial-chapter3 + URI chapter3 + VERSION 1.0 + QML_FILES + "ContactPage.qml" + "ConversationPage.qml" + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter3 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter3 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter3/ContactPage.qml index 080d8bdb30..b0be22718e 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/ContactPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter3/ContactPage.qml @@ -76,11 +76,11 @@ Page { width: listView.width - listView.leftMargin - listView.rightMargin height: avatar.implicitHeight leftPadding: avatar.implicitWidth + 32 - onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: modelData }) + onClicked: root.StackView.view.push("ConversationPage.qml", { inConversationWith: modelData }) Image { id: avatar - source: "qrc:/" + modelData.replace(" ", "_") + ".png" + source: "images/" + modelData.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter3/ConversationPage.qml index 2ae56444c7..2ae56444c7 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/ConversationPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter3/ConversationPage.qml diff --git a/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro b/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro new file mode 100644 index 0000000000..a5e500d9db --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/chapter3.pro @@ -0,0 +1,27 @@ +TEMPLATE = app + +QT += qml quick +CONFIG += c++11 + +SOURCES += main.cpp + +RESOURCES += \ + ContactPage.qml \ + ConversationPage.qml \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter3 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein.png Binary files differnew file mode 100644 index 0000000000..7c44b90b8d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@2x.png Binary files differnew file mode 100644 index 0000000000..6ce9c39b6c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@3x.png Binary files differnew file mode 100644 index 0000000000..aab6a6a162 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@4x.png Binary files differnew file mode 100644 index 0000000000..3611284df4 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway.png Binary files differnew file mode 100644 index 0000000000..3ac8992fd9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@2x.png Binary files differnew file mode 100644 index 0000000000..122d9f1e53 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@3x.png Binary files differnew file mode 100644 index 0000000000..2fe9c2cc1c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@4x.png Binary files differnew file mode 100644 index 0000000000..96fb6788b5 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude.png Binary files differnew file mode 100644 index 0000000000..907e38bc61 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@2x.png Binary files differnew file mode 100644 index 0000000000..6837796a83 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@3x.png Binary files differnew file mode 100644 index 0000000000..29af422ad3 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@4x.png Binary files differnew file mode 100644 index 0000000000..bc35eeaa79 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter3/images/images.qrc b/examples/quickcontrols2/chattutorial/chapter3/images/images.qrc new file mode 100644 index 0000000000..9eda6aa29c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/images/images.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>Albert_Einstein.png</file> + <file>Albert_Einstein@2x.png</file> + <file>Albert_Einstein@3x.png</file> + <file>Albert_Einstein@4x.png</file> + <file>Ernest_Hemingway.png</file> + <file>Ernest_Hemingway@2x.png</file> + <file>Ernest_Hemingway@3x.png</file> + <file>Ernest_Hemingway@4x.png</file> + <file>Hans_Gude.png</file> + <file>Hans_Gude@2x.png</file> + <file>Hans_Gude@3x.png</file> + <file>Hans_Gude@4x.png</file> + </qresource> +</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.cpp b/examples/quickcontrols2/chattutorial/chapter3/main.cpp index ea20c89012..657318a775 100644 --- a/examples/quickcontrols2/chattutorial/chapter1-settingup/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter3/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter3/main.qml"))); return app.exec(); } diff --git a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml b/examples/quickcontrols2/chattutorial/chapter3/main.qml index 029f45e3c8..029f45e3c8 100644 --- a/examples/quickcontrols2/chattutorial/chapter3-navigation/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter3/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter3/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter3/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter3/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter4-models/CMakeLists.txt deleted file mode 100644 index 6c11375ed5..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter4-models/CMakeLists.txt +++ /dev/null @@ -1,83 +0,0 @@ -# Generated from chapter4-models.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter4-models 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}/quickcontrols2/chattutorial/chapter4-models") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Sql) - -qt_add_executable(chapter4-models - main.cpp - sqlcontactmodel.cpp sqlcontactmodel.h - sqlconversationmodel.cpp sqlconversationmodel.h -) -set_target_properties(chapter4-models PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter4-models PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick - Qt::Sql -) - - -# Resources: -set(qml_resource_files - "ContactPage.qml" - "ConversationPage.qml" - "main.qml" -) - -qt6_add_resources(chapter4-models "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter4-models "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter4-models - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro b/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro deleted file mode 100644 index 2a2d955b1a..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter4-models/chapter4-models.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app - -QT += qml quick sql -CONFIG += c++11 - -HEADERS += sqlcontactmodel.h \ - sqlconversationmodel.h - -SOURCES += main.cpp \ - sqlcontactmodel.cpp \ - sqlconversationmodel.cpp - -RESOURCES += \ - qml.qrc \ - ../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter4-models -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/qml.qrc b/examples/quickcontrols2/chattutorial/chapter4-models/qml.qrc deleted file mode 100644 index a72e1b7134..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter4-models/qml.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - <file>ContactPage.qml</file> - <file>ConversationPage.qml</file> - </qresource> -</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter4/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter4/CMakeLists.txt new file mode 100644 index 0000000000..aba8c1000b --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter4 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter4") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick Sql) + +qt_add_executable(chattutorial-chapter4 WIN32 MACOSX_BUNDLE + main.cpp + sqlcontactmodel.cpp sqlcontactmodel.h + sqlconversationmodel.cpp sqlconversationmodel.h +) +target_link_libraries(chattutorial-chapter4 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick + Qt::Sql +) + +# Resources: +qt_add_qml_module(chattutorial-chapter4 + URI chapter4 + VERSION 1.0 + QML_FILES + "ContactPage.qml" + "ConversationPage.qml" + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter4 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter4 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter4/ContactPage.qml index c8e8872420..e0fc2e12c9 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/ContactPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter4/ContactPage.qml @@ -78,11 +78,11 @@ Page { width: listView.width - listView.leftMargin - listView.rightMargin height: avatar.implicitHeight leftPadding: avatar.implicitWidth + 32 - onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: model.display }) + onClicked: root.StackView.view.push("ConversationPage.qml", { inConversationWith: model.display }) Image { id: avatar - source: "qrc:/" + model.display.replace(" ", "_") + ".png" + source: "images/" + model.display.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter4/ConversationPage.qml index 35f770f58b..f69ebcd467 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/ConversationPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter4/ConversationPage.qml @@ -104,7 +104,7 @@ Page { Image { id: avatar - source: !sentByMe ? "qrc:/" + model.author.replace(" ", "_") + ".png" : "" + source: !sentByMe ? "images/" + model.author.replace(" ", "_") + ".png" : "" } Rectangle { diff --git a/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro b/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro new file mode 100644 index 0000000000..dd2241355b --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/chapter4.pro @@ -0,0 +1,32 @@ +TEMPLATE = app + +QT += qml quick sql +CONFIG += c++11 + +HEADERS += sqlcontactmodel.h \ + sqlconversationmodel.h + +SOURCES += main.cpp \ + sqlcontactmodel.cpp \ + sqlconversationmodel.cpp + +RESOURCES += \ + ContactPage.qml \ + ConversationPage.qml \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter4 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein.png Binary files differnew file mode 100644 index 0000000000..7c44b90b8d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@2x.png Binary files differnew file mode 100644 index 0000000000..6ce9c39b6c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@3x.png Binary files differnew file mode 100644 index 0000000000..aab6a6a162 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@4x.png Binary files differnew file mode 100644 index 0000000000..3611284df4 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway.png Binary files differnew file mode 100644 index 0000000000..3ac8992fd9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@2x.png Binary files differnew file mode 100644 index 0000000000..122d9f1e53 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@3x.png Binary files differnew file mode 100644 index 0000000000..2fe9c2cc1c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@4x.png Binary files differnew file mode 100644 index 0000000000..96fb6788b5 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude.png Binary files differnew file mode 100644 index 0000000000..907e38bc61 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@2x.png Binary files differnew file mode 100644 index 0000000000..6837796a83 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@3x.png Binary files differnew file mode 100644 index 0000000000..29af422ad3 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@4x.png Binary files differnew file mode 100644 index 0000000000..bc35eeaa79 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter4/images/images.qrc b/examples/quickcontrols2/chattutorial/chapter4/images/images.qrc new file mode 100644 index 0000000000..9eda6aa29c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/images/images.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>Albert_Einstein.png</file> + <file>Albert_Einstein@2x.png</file> + <file>Albert_Einstein@3x.png</file> + <file>Albert_Einstein@4x.png</file> + <file>Ernest_Hemingway.png</file> + <file>Ernest_Hemingway@2x.png</file> + <file>Ernest_Hemingway@3x.png</file> + <file>Ernest_Hemingway@4x.png</file> + <file>Hans_Gude.png</file> + <file>Hans_Gude@2x.png</file> + <file>Hans_Gude@3x.png</file> + <file>Hans_Gude@4x.png</file> + </qresource> +</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/main.cpp b/examples/quickcontrols2/chattutorial/chapter4/main.cpp index bbe7b3ad66..e4a06399e8 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter4/main.cpp @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) connectToDatabase(); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter4/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/main.qml b/examples/quickcontrols2/chattutorial/chapter4/main.qml index 029f45e3c8..029f45e3c8 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter4/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter4/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter4/qtquickcontrols2.conf new file mode 100644 index 0000000000..db9486764e --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter4/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Basic diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.cpp b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.cpp index 6203ebec1e..6203ebec1e 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.h b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.h index 5953c76258..5953c76258 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlcontactmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlcontactmodel.h diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.cpp b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.cpp index 99526e81d3..99526e81d3 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.h b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.h index 9c65d64a84..9c65d64a84 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/sqlconversationmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter4/sqlconversationmodel.h diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter5-styling/CMakeLists.txt deleted file mode 100644 index 80a9bde0e1..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/CMakeLists.txt +++ /dev/null @@ -1,86 +0,0 @@ -# Generated from chapter5-styling.pro. - -cmake_minimum_required(VERSION 3.16) -project(chapter5-styling 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}/quickcontrols2/chattutorial/chapter5-styling") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS Sql) - -qt_add_executable(chapter5-styling - main.cpp - sqlcontactmodel.cpp sqlcontactmodel.h - sqlconversationmodel.cpp sqlconversationmodel.h -) -set_target_properties(chapter5-styling PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(chapter5-styling PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick - Qt::Sql -) - - -# Resources: -set(qml_resource_files - "+Material/ChatToolBar.qml" - "ChatToolBar.qml" - "ContactPage.qml" - "ConversationPage.qml" - "main.qml" - "qtquickcontrols2.conf" -) - -qt6_add_resources(chapter5-styling "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) -set(shared_resource_files - "../shared/Albert_Einstein.png" - "../shared/Albert_Einstein@2x.png" - "../shared/Albert_Einstein@3x.png" - "../shared/Albert_Einstein@4x.png" - "../shared/Ernest_Hemingway.png" - "../shared/Ernest_Hemingway@2x.png" - "../shared/Ernest_Hemingway@3x.png" - "../shared/Ernest_Hemingway@4x.png" - "../shared/Hans_Gude.png" - "../shared/Hans_Gude@2x.png" - "../shared/Hans_Gude@3x.png" - "../shared/Hans_Gude@4x.png" -) - -qt6_add_resources(chapter5-styling "shared" - PREFIX - "/" - BASE - "../shared" - FILES - ${shared_resource_files} -) - -install(TARGETS chapter5-styling - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro b/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro deleted file mode 100644 index e798fe3cd7..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/chapter5-styling.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app - -QT += qml quick sql -CONFIG += c++11 - -HEADERS += sqlcontactmodel.h \ - sqlconversationmodel.h - -SOURCES += main.cpp \ - sqlcontactmodel.cpp \ - sqlconversationmodel.cpp - -RESOURCES += \ - qml.qrc \ - ../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter5-styling -INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/qml.qrc b/examples/quickcontrols2/chattutorial/chapter5-styling/qml.qrc deleted file mode 100644 index 54cf6d5a99..0000000000 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/qml.qrc +++ /dev/null @@ -1,10 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>main.qml</file> - <file>ContactPage.qml</file> - <file>ConversationPage.qml</file> - <file>qtquickcontrols2.conf</file> - <file>ChatToolBar.qml</file> - <file>+Material/ChatToolBar.qml</file> - </qresource> -</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/+Material/ChatToolBar.qml b/examples/quickcontrols2/chattutorial/chapter5/+Material/ChatToolBar.qml index d4a66764bd..d4a66764bd 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/+Material/ChatToolBar.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/+Material/ChatToolBar.qml diff --git a/examples/quickcontrols2/chattutorial/chapter5/CMakeLists.txt b/examples/quickcontrols2/chattutorial/chapter5/CMakeLists.txt new file mode 100644 index 0000000000..1d39757f1d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/CMakeLists.txt @@ -0,0 +1,65 @@ +cmake_minimum_required(VERSION 3.16) +project(chapter5 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quickcontrols2/chattutorial/chapter5") + +find_package(Qt6 COMPONENTS Core Gui Qml Quick Sql) + +qt_add_executable(chattutorial-chapter5 WIN32 MACOSX_BUNDLE + main.cpp + sqlcontactmodel.cpp sqlcontactmodel.h + sqlconversationmodel.cpp sqlconversationmodel.h +) +target_link_libraries(chattutorial-chapter5 PRIVATE + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick + Qt::Sql +) + +# Resources: +qt_add_qml_module(chattutorial-chapter5 + URI chapter5 + VERSION 1.0 + QML_FILES + "+Material/ChatToolBar.qml" + "ChatToolBar.qml" + "ContactPage.qml" + "ConversationPage.qml" + "main.qml" + RESOURCES + "images/Albert_Einstein.png" + "images/Albert_Einstein@2x.png" + "images/Albert_Einstein@3x.png" + "images/Albert_Einstein@4x.png" + "images/Ernest_Hemingway.png" + "images/Ernest_Hemingway@2x.png" + "images/Ernest_Hemingway@3x.png" + "images/Ernest_Hemingway@4x.png" + "images/Hans_Gude.png" + "images/Hans_Gude@2x.png" + "images/Hans_Gude@3x.png" + "images/Hans_Gude@4x.png" +) + +qt6_add_resources(chattutorial-chapter5 "conf" + PREFIX + "/" + FILES + "qtquickcontrols2.conf" +) + +install(TARGETS chattutorial-chapter5 + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml b/examples/quickcontrols2/chattutorial/chapter5/ChatToolBar.qml index c192aeb51a..c192aeb51a 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/ChatToolBar.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/ChatToolBar.qml diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml b/examples/quickcontrols2/chattutorial/chapter5/ContactPage.qml index 65460bf127..34a138edca 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/ContactPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/ContactPage.qml @@ -78,11 +78,11 @@ Page { width: listView.width - listView.leftMargin - listView.rightMargin height: avatar.implicitHeight leftPadding: avatar.implicitWidth + 32 - onClicked: root.StackView.view.push("qrc:/ConversationPage.qml", { inConversationWith: model.display }) + onClicked: root.StackView.view.push("ConversationPage.qml", { inConversationWith: model.display }) Image { id: avatar - source: "qrc:/" + model.display.replace(" ", "_") + ".png" + source: "images/" + model.display.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml b/examples/quickcontrols2/chattutorial/chapter5/ConversationPage.qml index c668072e34..60dbc4a2ee 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/ConversationPage.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/ConversationPage.qml @@ -104,7 +104,7 @@ Page { Image { id: avatar - source: !sentByMe ? "qrc:/" + model.author.replace(" ", "_") + ".png" : "" + source: !sentByMe ? "images/" + model.author.replace(" ", "_") + ".png" : "" } Rectangle { diff --git a/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro b/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro new file mode 100644 index 0000000000..1ca8998427 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/chapter5.pro @@ -0,0 +1,34 @@ +TEMPLATE = app + +QT += qml quick sql +CONFIG += c++11 + +HEADERS += sqlcontactmodel.h \ + sqlconversationmodel.h + +SOURCES += main.cpp \ + sqlcontactmodel.cpp \ + sqlconversationmodel.cpp + +RESOURCES += \ + +Material/ChatToolBar.qml \ + ChatToolBar.qml \ + ContactPage.qml \ + ConversationPage.qml \ + images/Albert_Einstein.png \ + images/Albert_Einstein@2x.png \ + images/Albert_Einstein@3x.png \ + images/Albert_Einstein@4x.png \ + images/Ernest_Hemingway.png \ + images/Ernest_Hemingway@2x.png \ + images/Ernest_Hemingway@3x.png \ + images/Ernest_Hemingway@4x.png \ + images/Hans_Gude.png \ + images/Hans_Gude@2x.png \ + images/Hans_Gude@3x.png \ + images/Hans_Gude@4x.png \ + main.qml \ + qtquickcontrols2.conf + +target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols2/chattutorial/chapter5 +INSTALLS += target diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein.png Binary files differnew file mode 100644 index 0000000000..7c44b90b8d --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@2x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@2x.png Binary files differnew file mode 100644 index 0000000000..6ce9c39b6c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@3x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@3x.png Binary files differnew file mode 100644 index 0000000000..aab6a6a162 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@4x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@4x.png Binary files differnew file mode 100644 index 0000000000..3611284df4 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Albert_Einstein@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway.png Binary files differnew file mode 100644 index 0000000000..3ac8992fd9 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@2x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@2x.png Binary files differnew file mode 100644 index 0000000000..122d9f1e53 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@3x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@3x.png Binary files differnew file mode 100644 index 0000000000..2fe9c2cc1c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@4x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@4x.png Binary files differnew file mode 100644 index 0000000000..96fb6788b5 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Ernest_Hemingway@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude.png Binary files differnew file mode 100644 index 0000000000..907e38bc61 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@2x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@2x.png Binary files differnew file mode 100644 index 0000000000..6837796a83 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@2x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@3x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@3x.png Binary files differnew file mode 100644 index 0000000000..29af422ad3 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@3x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@4x.png b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@4x.png Binary files differnew file mode 100644 index 0000000000..bc35eeaa79 --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/Hans_Gude@4x.png diff --git a/examples/quickcontrols2/chattutorial/chapter5/images/images.qrc b/examples/quickcontrols2/chattutorial/chapter5/images/images.qrc new file mode 100644 index 0000000000..9eda6aa29c --- /dev/null +++ b/examples/quickcontrols2/chattutorial/chapter5/images/images.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/"> + <file>Albert_Einstein.png</file> + <file>Albert_Einstein@2x.png</file> + <file>Albert_Einstein@3x.png</file> + <file>Albert_Einstein@4x.png</file> + <file>Ernest_Hemingway.png</file> + <file>Ernest_Hemingway@2x.png</file> + <file>Ernest_Hemingway@3x.png</file> + <file>Ernest_Hemingway@4x.png</file> + <file>Hans_Gude.png</file> + <file>Hans_Gude@2x.png</file> + <file>Hans_Gude@3x.png</file> + <file>Hans_Gude@4x.png</file> + </qresource> +</RCC> diff --git a/examples/quickcontrols2/chattutorial/chapter4-models/main.cpp b/examples/quickcontrols2/chattutorial/chapter5/main.cpp index bbe7b3ad66..74e66106d4 100644 --- a/examples/quickcontrols2/chattutorial/chapter4-models/main.cpp +++ b/examples/quickcontrols2/chattutorial/chapter5/main.cpp @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) connectToDatabase(); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + engine.load(QUrl(QStringLiteral("qrc:/chapter5/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml b/examples/quickcontrols2/chattutorial/chapter5/main.qml index 029f45e3c8..029f45e3c8 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/main.qml +++ b/examples/quickcontrols2/chattutorial/chapter5/main.qml diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/qtquickcontrols2.conf b/examples/quickcontrols2/chattutorial/chapter5/qtquickcontrols2.conf index e338c80432..c8a8eeeb05 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/qtquickcontrols2.conf +++ b/examples/quickcontrols2/chattutorial/chapter5/qtquickcontrols2.conf @@ -1,4 +1,7 @@ -[material] +[Controls] +Style=Basic + +[Material] Primary=Indigo Accent=Indigo Theme=Dark diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.cpp b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.cpp index 6203ebec1e..6203ebec1e 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.h b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.h index 5953c76258..5953c76258 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlcontactmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlcontactmodel.h diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.cpp b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.cpp index 99526e81d3..99526e81d3 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.cpp +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.cpp diff --git a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.h b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.h index 9c65d64a84..9c65d64a84 100644 --- a/examples/quickcontrols2/chattutorial/chapter5-styling/sqlconversationmodel.h +++ b/examples/quickcontrols2/chattutorial/chapter5/sqlconversationmodel.h diff --git a/examples/quickcontrols2/chattutorial/chattutorial.pro b/examples/quickcontrols2/chattutorial/chattutorial.pro index 2f38254ed8..1c70b2653e 100644 --- a/examples/quickcontrols2/chattutorial/chattutorial.pro +++ b/examples/quickcontrols2/chattutorial/chattutorial.pro @@ -1,8 +1,8 @@ TEMPLATE = subdirs SUBDIRS += \ - chapter1-settingup \ - chapter2-lists \ - chapter3-navigation \ - chapter4-models \ - chapter5-styling + chapter1 \ + chapter2 \ + chapter3 \ + chapter4 \ + chapter5 diff --git a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc index a56a470379..5d9cab68c7 100644 --- a/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc +++ b/examples/quickcontrols2/chattutorial/doc/src/qtquickcontrols2-chattutorial.qdoc @@ -52,14 +52,14 @@ basic "Hello World" application with the following files: \li \c chattutorial.pro - Provides the qmake configuration \endlist -\note Delete the \c MainForm.ui.qml from the project as we will -not use it in this tutorial. +\note Delete the \c MainForm.ui.qml and \c qml.qrc files from the project, as +we will not use them in this tutorial. \section2 main.cpp The default code in \c main.cpp has two includes: -\quotefromfile chattutorial/chapter1-settingup/main.cpp +\quotefromfile chattutorial/chapter1/main.cpp \skipto include \printline include \printline include @@ -96,7 +96,7 @@ Once we've set up things in C++, we can move on to the user interface in QML. Let's modify the default QML code to suit our needs. -\quotefromfile chattutorial/chapter1-settingup/main.qml +\quotefromfile chattutorial/chapter1/main.qml \skipto import \printuntil import QtQuick.Controls @@ -145,7 +145,7 @@ which screen the user is viewing, it is much easier to use \l Page. For now, we'll just add one page, but in the next chapter, we'll demonstrate how to navigate between several pages. -\quotefromfile chattutorial/chapter1-settingup/main.qml +\quotefromfile chattutorial/chapter1/main.qml \skipto Page \printuntil } \printuntil } @@ -183,7 +183,7 @@ The \c .pro or \l {Creating Project Files}{project} file contains all of the information needed by \l {qmake Manual}{qmake} to generate a Makefile, which is then used to compile and link the application. -\quotefromfile chattutorial/chapter1-settingup/chapter1-settingup.pro +\quotefromfile chattutorial/chapter1/chapter1.pro \printline TEMPLATE The first line tells \c qmake which kind of project this is. We're building an @@ -234,7 +234,7 @@ can display text, be checked on and off, and react to mouse clicks. Here is our ListView: -\quotefromfile chattutorial/chapter2-lists/main.qml +\quotefromfile chattutorial/chapter2/main.qml \dots 8 \codeline \skipto ListView @@ -303,7 +303,7 @@ vertical space. In this chapter, you'll learn how to use \l StackView to navigate between pages in an application. Here's the revised \c main.qml: -\quotefromfile chattutorial/chapter3-navigation/main.qml +\quotefromfile chattutorial/chapter3/main.qml \skipto import \printuntil } \printuntil } @@ -362,7 +362,7 @@ application-wide and context-sensitive actions and controls, such as navigation buttons and search fields. Best of all, it has a background color that, as usual, comes from the application style. Here it is in action: -\quotefromfile chattutorial/chapter3-navigation/ContactPage.qml +\quotefromfile chattutorial/chapter3/ContactPage.qml \skipto header \printuntil } \printuntil } @@ -389,7 +389,7 @@ name, which it then uses to display the relevant conversation. Note the Let's step through \c ConversationPage.qml, beginning with the imports: -\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml +\quotefromfile chattutorial/chapter3/ConversationPage.qml \skipto import \printline import \printline import @@ -459,7 +459,7 @@ accommodating the Pane. Let's look at the listview in detail: -\quotefromfile chattutorial/chapter3-navigation/ConversationPage.qml +\quotefromfile chattutorial/chapter3/ConversationPage.qml \skipto ListView \printuntil ScrollBar \printuntil } @@ -539,13 +539,13 @@ purpose, as it provides a read-only data model for SQL result sets. Let's take a look at our \c SqlContactModel class that derives from QSqlQueryModel: -\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.h +\quotefromfile chattutorial/chapter4/sqlcontactmodel.h \skipto #include \printuntil }; There's not much going on here, so let's move on to the \c .cpp file: -\quotefromfile chattutorial/chapter4-models/sqlcontactmodel.cpp +\quotefromfile chattutorial/chapter4/sqlcontactmodel.cpp \skipto #include \printuntil } \printuntil } @@ -572,7 +572,7 @@ all rows of the \c Contacts table. \c SqlConversationModel is more complex: -\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.h +\quotefromfile chattutorial/chapter4/sqlconversationmodel.h \skipto #include \printuntil }; @@ -592,7 +592,7 @@ QML, hence the \c Q_INVOKABLE macro. Let's take a look at the \c .cpp file: -\quotefromfile chattutorial/chapter4-models/sqlconversationmodel.cpp +\quotefromfile chattutorial/chapter4/sqlconversationmodel.cpp \skipto #include \printuntil } \printuntil } @@ -649,7 +649,7 @@ of \l QSqlTableModel::OnManualSubmit, we must manually call Now that we've established the model classes, let's take a look at \c main.cpp: -\quotefromfile chattutorial/chapter4-models/main.cpp +\quotefromfile chattutorial/chapter4/main.cpp \skipto #include \printuntil return app.exec(); \printuntil } @@ -666,7 +666,7 @@ Now that we have the models available as QML types, there are some minor changes to be done to \c ContactPage.qml. To be able to use the types, we must first import them using the URI we set in \c main.cpp: -\quotefromfile chattutorial/chapter4-models/ContactPage.qml +\quotefromfile chattutorial/chapter4/ContactPage.qml \skipto import io.qt.examples.chattutorial \printline import io.qt.examples.chattutorial @@ -683,7 +683,7 @@ Within the delegate, we use a different syntax for accessing the model data: In \c ConversationPage.qml, we add the same \c chattutorial import, and replace the dummy model: -\quotefromfile chattutorial/chapter4-models/ConversationPage.qml +\quotefromfile chattutorial/chapter4/ConversationPage.qml \skipto model: SqlConversationModel { \printuntil } @@ -792,7 +792,7 @@ means that it will be used when the \l {Basic Style}{Basic style} (which is the style that is used when none is specified) is in use. Here's the new file: -\quotefromfile chattutorial/chapter5-styling/ChatToolBar.qml +\quotefromfile chattutorial/chapter5/ChatToolBar.qml \skipto import \printuntil } @@ -803,7 +803,7 @@ of the file, nothing needs to be different. Back in \c ContactPage.qml, we update the code to use the new type: -\quotefromfile chattutorial/chapter5-styling/ContactPage.qml +\quotefromfile chattutorial/chapter5/ContactPage.qml \skipto ToolBar \printuntil } \printuntil } @@ -817,13 +817,13 @@ that the selection feature is not accidentally triggered. Here's \c +Material/ChatToolBar.qml: -\quotefromfile chattutorial/chapter5-styling/+Material/ChatToolBar.qml +\quotefromfile chattutorial/chapter5/+Material/ChatToolBar.qml \skipto import \printuntil } We'll make the same changes to \c ConversationPage.qml: -\quotefromfile chattutorial/chapter5-styling/ConversationPage.qml +\quotefromfile chattutorial/chapter5/ConversationPage.qml \skipto header: ChatToolBar \printuntil } \printuntil } |