diff options
Diffstat (limited to 'examples/quickcontrols/chattutorial/chapter2')
-rw-r--r-- | examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt | 6 | ||||
-rw-r--r-- | examples/quickcontrols/chattutorial/chapter2/Main.qml (renamed from examples/quickcontrols/chattutorial/chapter2/main.qml) | 9 | ||||
-rw-r--r-- | examples/quickcontrols/chattutorial/chapter2/chapter2.pro | 6 | ||||
-rw-r--r-- | examples/quickcontrols/chattutorial/chapter2/main.cpp | 4 | ||||
-rw-r--r-- | examples/quickcontrols/chattutorial/chapter2/qmldir | 2 |
5 files changed, 17 insertions, 10 deletions
diff --git a/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt b/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt index bc531ef529..dd2835740c 100644 --- a/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt +++ b/examples/quickcontrols/chattutorial/chapter2/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2022 The Qt Company Ltd. +# Copyright (C) 2023 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause cmake_minimum_required(VERSION 3.16) @@ -27,9 +27,9 @@ target_link_libraries(chattutorial-chapter2 PRIVATE qt_policy(SET QTP0001 NEW) qt_add_qml_module(chattutorial-chapter2 - URI chapter2 + URI chattutorial QML_FILES - "main.qml" + "Main.qml" RESOURCES "images/Albert_Einstein.png" "images/[email protected]" diff --git a/examples/quickcontrols/chattutorial/chapter2/main.qml b/examples/quickcontrols/chattutorial/chapter2/Main.qml index 851b482b01..daa4360fb9 100644 --- a/examples/quickcontrols/chattutorial/chapter2/main.qml +++ b/examples/quickcontrols/chattutorial/chapter2/Main.qml @@ -1,6 +1,8 @@ -// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Controls @@ -29,14 +31,17 @@ ApplicationWindow { spacing: 20 model: ["Albert Einstein", "Ernest Hemingway", "Hans Gude"] delegate: ItemDelegate { + id: contactDelegate text: modelData width: listView.width - listView.leftMargin - listView.rightMargin height: avatar.implicitHeight leftPadding: avatar.implicitWidth + 32 + required property string modelData + Image { id: avatar - source: "images/" + modelData.replace(" ", "_") + ".png" + source: "images/" + contactDelegate.modelData.replace(" ", "_") + ".png" } } } diff --git a/examples/quickcontrols/chattutorial/chapter2/chapter2.pro b/examples/quickcontrols/chattutorial/chapter2/chapter2.pro index 8679db986a..88f70ce08a 100644 --- a/examples/quickcontrols/chattutorial/chapter2/chapter2.pro +++ b/examples/quickcontrols/chattutorial/chapter2/chapter2.pro @@ -1,7 +1,6 @@ TEMPLATE = app QT += qml quick -CONFIG += c++11 SOURCES += main.cpp @@ -18,8 +17,9 @@ resources.files = \ images/[email protected] \ images/[email protected] \ images/[email protected] \ - main.qml -resources.prefix = qt/qml/chapter2/ + Main.qml \ + qmldir +resources.prefix = qt/qml/chattutorial/ RESOURCES += resources \ qtquickcontrols2.conf diff --git a/examples/quickcontrols/chattutorial/chapter2/main.cpp b/examples/quickcontrols/chattutorial/chapter2/main.cpp index 07f034a827..73d4bf3b63 100644 --- a/examples/quickcontrols/chattutorial/chapter2/main.cpp +++ b/examples/quickcontrols/chattutorial/chapter2/main.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2023 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QGuiApplication> @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/qt/qml/chapter2/main.qml"))); + engine.loadFromModule("chattutorial", "Main"); return app.exec(); } diff --git a/examples/quickcontrols/chattutorial/chapter2/qmldir b/examples/quickcontrols/chattutorial/chapter2/qmldir new file mode 100644 index 0000000000..1044557225 --- /dev/null +++ b/examples/quickcontrols/chattutorial/chapter2/qmldir @@ -0,0 +1,2 @@ +module chattutorial +Main 1.0 Main.qml |