Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.10.1
-
None
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.