QMLlint warning for ids
-
Hi,
Item {
id: root
property int deleteIndex: -1ListView{
id: acList
anchors.fill: parent
model: _my_model
delegate: Rectangle {
id: gridDelegate
height: 40
width: parent.width
anchors.left: parent.left
Image {
id: deleteIcon
source: (root.deleteIndex == index) ? "qrc:/images/A.png" : "qrc:/images/B.png"
}
}
}
I am getting the following error in the bold text -
ReferenceError: index is not defined,Please let me know the solution -
Hi @IamSumit , It looks like your 'index' isn't defined in the scope of 'Image', it's scoped as part of the delegate.
You can either define a property in the delegate scope or try to use model.index. -
Hi,
Item {
id: root
property int deleteIndex: -1ListView{
id: acList
anchors.fill: parent
model: _my_model
delegate: Rectangle {
id: gridDelegate
height: 40
width: parent.width
anchors.left: parent.left
Image {
id: deleteIcon
source: (root.deleteIndex == index) ? "qrc:/images/A.png" : "qrc:/images/B.png"
}
}
}
I am getting the following error in the bold text -
ReferenceError: index is not defined,Please let me know the solution- You need
required property int index
in gridDelegate (see https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#view-delegates ) - deleteIndex is qualified (this is good), but index is unqualified (this is bad). Qualify index too:
root.deleteIndex == gridDelegate.index
(see https://doc.qt.io/qt-6/qmllint-warnings-and-errors-unqualified.html )
- You need