diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-06-14 17:59:48 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-06-21 10:31:23 +0200 |
commit | 2a882ddf5846319fe9b67fbf84ea6816b5bf6a93 (patch) | |
tree | 3e2de81a7e12e143eddba44407f244b3c6b97d26 /examples | |
parent | 23956255e2c4d668ac8b8969399513927697ff45 (diff) |
CoAP Multicast Discovery example: fix qmllint warnings
The example had a bunch of unqualified access warnings.
Fix them by doing the following:
* use 'pragma ComponentBehavior: Bound' to limit the context of the
delegates, and introduce required properties to pass needed data to
them
* add some missing ids and explicitly use them when accessing the
objects
Task-number: QTBUG-113858
Pick-to: 6.6 6.5
Change-Id: If42661c3c8272f16edfa2d0e21466cf254062184
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/coap/quickmulticastclient/Main.qml | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/examples/coap/quickmulticastclient/Main.qml b/examples/coap/quickmulticastclient/Main.qml index c75130d..86dbd48 100644 --- a/examples/coap/quickmulticastclient/Main.qml +++ b/examples/coap/quickmulticastclient/Main.qml @@ -1,13 +1,16 @@ // Copyright (C) 2019 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +pragma ComponentBehavior: Bound + import QtQuick import QtQuick.Window import QtQuick.Controls import QtQuick.Layouts -import CoapClientModule Window { + id: root + visible: true width: 480 height: 480 @@ -21,7 +24,7 @@ Window { CoapMulticastClient { id: client - onDiscovered: (resource) => { addResource(resource) } + onDiscovered: (resource) => { root.addResource(resource) } onFinished: (error) => { statusLabel.text = (error === QtCoap.Error.Ok) @@ -71,10 +74,16 @@ Window { } delegate: ItemDelegate { + id: entry + + required property int index + required property string group + required property string address + width: groupComboBox.width contentItem: Column { - Text { text: group } - Text { text: address } + Text { text: entry.group } + Text { text: entry.address } } highlighted: groupComboBox.highlightedIndex === index } @@ -147,6 +156,12 @@ Window { Layout.fillWidth: true delegate: Rectangle { + id: resourceItem + + required property string host + required property string path + required property string title + width: resourceView.width height: 60 color: "lightgray" @@ -156,9 +171,9 @@ Window { Column { topPadding: 5 leftPadding: 5 - Text { text: qsTr('<b>Host:</b> %1').arg(host) } - Text { text: qsTr('<b>Resource:</b> %1').arg(path) } - Text { text: qsTr('<b>Title:</b> %1').arg(title) } + Text { text: qsTr('<b>Host:</b> %1').arg(resourceItem.host) } + Text { text: qsTr('<b>Resource:</b> %1').arg(resourceItem.path) } + Text { text: qsTr('<b>Title:</b> %1').arg(resourceItem.title) } } } } |