aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/models/objectlistmodel
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2021-11-11 16:36:38 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-12 15:41:53 +0000
commit0a86a3bdb4536b8d3b29e42fbca3cf46530cd9cc (patch)
treecbe7ece7ef05eeaf3ea458df3568e9f342117ad5 /examples/quick/models/objectlistmodel
parent3b0b18a5cd54b2f73c54de8530a49d4137d49e73 (diff)
Model examples: use new cmake api
The models directory contains 3 subdirectories with an example project in each. This patch updates the CMakeLists.txt files to use qt_add_qml_module() instead of the old qt_add_resources(). In order to achieve intercompatibility with both cmake and qmake, I had to do some slight modifications to both the .qrc files and the url path used to set the source to the QQuickView. Task-number: QTBUG-98130 Change-Id: I13d1c01a0eda181823f394bc2a4259ce98abd4f8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit a155b3bc3ee161fbb7ff1760781577700b0aafce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples/quick/models/objectlistmodel')
-rw-r--r--examples/quick/models/objectlistmodel/CMakeLists.txt32
-rw-r--r--examples/quick/models/objectlistmodel/dataobject.cpp2
-rw-r--r--examples/quick/models/objectlistmodel/main.cpp4
-rw-r--r--examples/quick/models/objectlistmodel/objectlistmodel.qrc2
-rw-r--r--examples/quick/models/objectlistmodel/view.qml4
5 files changed, 16 insertions, 28 deletions
diff --git a/examples/quick/models/objectlistmodel/CMakeLists.txt b/examples/quick/models/objectlistmodel/CMakeLists.txt
index 60fdeea219..8dbee3ae0b 100644
--- a/examples/quick/models/objectlistmodel/CMakeLists.txt
+++ b/examples/quick/models/objectlistmodel/CMakeLists.txt
@@ -7,7 +7,6 @@ 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")
@@ -15,20 +14,13 @@ endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/models/objectlistmodel")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Quick)
+find_package(Qt6 COMPONENTS Core Gui Qml Quick)
-qt_add_executable(objectlistmodel
- dataobject.cpp dataobject.h
+qt_add_executable(objectlistmodelexample WIN32 MACOSX_BUNDLE
+ dataobject.cpp
main.cpp
)
-set_target_properties(objectlistmodel PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(objectlistmodel PUBLIC
+target_link_libraries(objectlistmodelexample PUBLIC
Qt::Core
Qt::Gui
Qt::Qml
@@ -37,18 +29,14 @@ target_link_libraries(objectlistmodel PUBLIC
# Resources:
-set(objectlistmodel_resource_files
- "view.qml"
-)
-
-qt6_add_resources(objectlistmodel "objectlistmodel"
- PREFIX
- "/"
- FILES
- ${objectlistmodel_resource_files}
+qt_add_qml_module(objectlistmodelexample
+ URI objectlistmodel
+ VERSION 1.0
+ QML_FILES
+ "view.qml"
)
-install(TARGETS objectlistmodel
+install(TARGETS objectlistmodelexample
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quick/models/objectlistmodel/dataobject.cpp b/examples/quick/models/objectlistmodel/dataobject.cpp
index 6963d75c42..354b9d74b4 100644
--- a/examples/quick/models/objectlistmodel/dataobject.cpp
+++ b/examples/quick/models/objectlistmodel/dataobject.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
diff --git a/examples/quick/models/objectlistmodel/main.cpp b/examples/quick/models/objectlistmodel/main.cpp
index 8fbe7c183c..cb8dac0638 100644
--- a/examples/quick/models/objectlistmodel/main.cpp
+++ b/examples/quick/models/objectlistmodel/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the demonstration applications of the Qt Toolkit.
@@ -80,7 +80,7 @@ int main(int argc, char ** argv)
view.setInitialProperties({{ "model", QVariant::fromValue(dataList) }});
//![0]
- view.setSource(QUrl("qrc:view.qml"));
+ view.setSource(QUrl("qrc:/objectlistmodel/view.qml"));
view.show();
return app.exec();
diff --git a/examples/quick/models/objectlistmodel/objectlistmodel.qrc b/examples/quick/models/objectlistmodel/objectlistmodel.qrc
index 17e9301471..a6e8cffb08 100644
--- a/examples/quick/models/objectlistmodel/objectlistmodel.qrc
+++ b/examples/quick/models/objectlistmodel/objectlistmodel.qrc
@@ -1,5 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
+<qresource prefix="/objectlistmodel">
<file>view.qml</file>
</qresource>
</RCC>
diff --git a/examples/quick/models/objectlistmodel/view.qml b/examples/quick/models/objectlistmodel/view.qml
index ba0c905e1e..e8ec6197dc 100644
--- a/examples/quick/models/objectlistmodel/view.qml
+++ b/examples/quick/models/objectlistmodel/view.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,7 +48,7 @@
**
****************************************************************************/
-import QtQuick 2.0
+import QtQuick
//![0]
ListView {