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

Nested+imported ListView header and footer id context is incorrect

    XMLWordPrintable

Details

    Description

      The attached .qml shows a nested ListView (id: section2), where the ListView is an imported component (ControlView.qml) ie.

      ListView {
          model: controlsmodel
          ...
      }
      VisualItemModel {
          id: controlsmodel
          ControlView {
              id: section 2
              controlname: "Phoenetic"
              ...
          }
          ...
      }
      

      and, ControlView

      ListView {
          id: controlviewitem
          property string controlname
          header: Rectangle { Text { text: controlviewitem.controlname } }
          footer: Rectangle { Text { text: controlviewitem.controlname } }
          ...
      }
      

      The property 'controlname' for the ControlView component cannot be accessed by the header/footer. Setting the text item to controlviewitem.controlname results in

      ControlView.qml:15: ReferenceError: Can't find variable: controlviewitem

      However, setting the header Text item to read the property from the main .qml component id i.e.

      text: section2.controlname

      seems to work - but obviously sets that for every following instance of the ControlView.

      Attachments

        1. ControlView.qml
          0.6 kB
        2. headertextbug.qml
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            denexter Andrew den Exter (closed Nokia identity) (Inactive)
            dajansen Damian Jansen (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes