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

Using PathView.view in a binding of an ObjectModel delegate produces null warning

    XMLWordPrintable

Details

    • Linux/Wayland

    Description

      Using PathView.view in binding produces cannot read property 'count' of null warning, where the binding doesn't recover. In Component.onCompleted phase the attached property is already available:
      import QtQuick 2.0
      import QtQml.Models 2.1

      Rectangle {
          id: root
          property int itemWidth: width
          property int itemHeight: height * 0.8
          width: 200
          height: 400
          PathView {
              anchors.fill: parent
              pathItemCount: 3
              path: Path {
                  startX: itemWidth/2; startY: -itemHeight + (root.height - itemHeight)/2
                  PathLine { x: itemWidth/2; y: 2*itemHeight + (root.height - itemHeight)/2 }
              }
              preferredHighlightBegin: 0.5; preferredHighlightEnd: 0.5
              highlight: Item {}
              model: ObjectModel {
                  Item {
                      property int index: ObjectModel.index
                      property int count: PathView.view.count
                      Component.onCompleted: console.log("PathView", ObjectModel.index, PathView.view.count, PathView.currentIndex)
                      width: itemWidth
                      height: itemHeight
                      Text {
                          anchors.centerIn: parent
                          text: (parent.index + 1) + "/" + parent.count
                      }
                  }
                  Item {
                      property int index: ObjectModel.index
                      property int count: PathView.view.count
                      Component.onCompleted: console.log("PathView", ObjectModel.index, PathView.view.count, PathView.currentIndex)
                      width: itemWidth
                      height: itemHeight
                      Text {
                          anchors.centerIn: parent
                          text: (parent.index + 1) + "/" + parent.count
                      }
                  }
                  Item {
                      property int index: ObjectModel.index
                      property int count: PathView.view.count
                      width: itemWidth
                      height: itemHeight
                      Text {
                          anchors.centerIn: parent
                          text: (parent.index + 1) + "/" + parent.count
                      }
                  }
                  Item {
                      property int index: ObjectModel.index
                      property int count: PathView.view.count
                      width: itemWidth
                      height: itemHeight
                      Text {
                          anchors.centerIn: parent
                          text: (parent.index + 1) + "/" + parent.count
                      }
                  }
                  Item {
                      property int index: ObjectModel.index
                      property int count: PathView.view.count
                      width: itemWidth
                      height: itemHeight
                      Text {
                          anchors.centerIn: parent
                          text: (parent.index + 1) + "/" + parent.count
                      }
                  }
              }
          }
      }
      In general it seems ObjectModel and PathView don't play along nicely, e.g. saw one ObjectModel delegate not getting reference to PathView.view at all (but other identical delegates did), unfortunately failed to produce simplified examples to reproduce to write a bug about it.

       

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            jpetrell Joona Petrell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes