Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QMLlint warning for ids
Forum Updated to NodeBB v4.3 + New Features

QMLlint warning for ids

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 147 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • IamSumitI Offline
    IamSumitI Offline
    IamSumit
    wrote last edited by IamSumit
    #1

    Hi,

    Item {
    id: root
    property int deleteIndex: -1

    ListView{
    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

    Be Cute

    JKSHJ 1 Reply Last reply
    0
    • B Offline
      B Offline
      Ben Campbell-Wallis
      wrote last edited by Ben Campbell-Wallis
      #2

      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.

      1 Reply Last reply
      1
      • IamSumitI IamSumit

        Hi,

        Item {
        id: root
        property int deleteIndex: -1

        ListView{
        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

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote last edited by
        #3
        1. You need required property int index in gridDelegate (see https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#view-delegates )
        2. 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 )

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved