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

Qml ListView highlight component cannot access ListView scope (ReferenceError)

    XMLWordPrintable

Details

    • 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

        For Gerrit Dashboard: QTBUG-26043
        # Subject Branch Project Status CR V

        Activity

          People

            martjone Martin Jones (closed Nokia identity) (Inactive)
            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