Reputation: 107
I have created one qml list using listview, I require list height but when i try to get the height of list using List.height, the output is zero. but count and contentHeight is coming properly. please suggest how to proceed,please find the below code.
Rectangle{
id:displayarea
anchors.top:subTitle.bottom
anchors.margins: 5
width: parent.width-8
height: parent.height-30
x:4
anchors.topMargin: 2
Image {
id: fileInfoImage
width: parent.width
height: parent.height-15
source: Model.imagePath+Model.imageName
fillMode: Image.PreserveAspectFit
}
listView {
id: list
spacing: 1
interactive: true
width: parent.width
focus: true
anchors {
left: recstring.left;
top: fileInfoImage.bottom;
rightMargin: 1
topMargin: 2;
right: scrollBar.left
}
delegate: listDelegate
model: MainModel
cacheBuffer: 50
onContentHeightChanged: {
console.log("scrollbar visibility",scrollBar.visible,list.height,list.contentHeight,height);
scrollBar.visible = list.height
< list.contentHeight
thumb.height = list.height
/ (list.contentHeight / list.height)
console.log("thumb height",thumb.height,list.height);
}
}
Component{
id: listDelegate
Item{
width: parent.width
implicitHeight: descriptionText.implicitHeight
Rectangle{
id: faultCode
width: scrollBar.visible ? recstring.width-10 : recstring.width-7;
height: parent.height
Text{
id:descriptionText
width:parent.width
text:(strType == 1)?(" \u2022 " +qsTr(disString)):qsTr(disString)
wrapMode: Text.Wrap
font.pixelSize: (text.length === 0) ? 2: 8
anchors {
margins: 1;
}
}
}
}
}
Upvotes: 0
Views: 1213
Reputation: 147
Your ListView
height property is not explicitly defined (even not defined at all).
So define height
property.
Or, you can try to define the bottom
property of your ListView
's anchors.
A remark : your ListView
's id is invalid:
IDs cannot start with an uppercase letter (M14)
Upvotes: 1