Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-26043

Qml ListView highlight component cannot access ListView scope (ReferenceError)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 4.8.1
    • Fix Version/s: 4.8.x
    • Labels:
      None
    • Commits:
      d25fc4c63fa4512aa1cfc5ce3877e4d8632b3fec

      Description

      The following example will result in a "ReferenceError: Can't find variable: reel" error message.

      Both "highlight" and "delegate" reference components. Why can't the highlight component reference the local "reel" id?

      main.qml
      import QtQuick 1.1
       
      Column {
        width: 300
        height: 300
       
        Reel {
          id: reelInstance // setting some local id here
        }
      }
      
      Reel.qml
      import QtQuick 1.1
       
      ListView {
        id: reel
        width: 100
        height: 100
       
        property string someProperty: "Bla!"
       
        highlight: Text {
          // results in "ReferenceError: Can't find variable: reel"
          text: ">>> " + reel.someProperty
        }
       
        delegate: Text {
          // interestingly: this works as expected
          text: "M " + reel.someProperty + " - " + modelData
        }
       
        model: 10
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            martjone Martin Jones (closed Nokia identity) (Inactive)
            Reporter:
            njeisecke Nils Jeisecke
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes