[Qt-qml] Issues with ListView and ChildrenRect
saravanane.dhandabani at nokia.com
saravanane.dhandabani at nokia.com
Wed Oct 12 02:51:26 CEST 2011
Hi,
I have below list view in my project that contains Rectangle item as delegate. Delegate item will be loaded with dynamic text contents from server.
So i use, childrenRect to determine the height/width of the items. But it always returns fixed ChildrenRect size.
Any pointers, what was wrong with the code?
Cheers,
Saravanane
ListView {
z: 1000;
visible: !api.fetchProfileData
id: positionlist
anchors.fill: parent
anchors.topMargin: 60
model: api.profileData.positionList
delegate: Rectangle {
x: 5; width: 470; radius: 5; y: 100
border.color: "black"
height: childrenRect.height
width: childrenRect.width
Text {
id: positionTitle
text: modelData.positionTitle
x: 15; y: 15
font.bold: true
font.pixelSize: 22
textFormat: Text.AutoText
wrapMode: Text.Wrap
}
Text {
text: modelData.companyName
x: 15; anchors.top: positionTitle.bottom; anchors.topMargin: 5
id: companyName
color: "blue"
font.bold: true
font.pixelSize: 20
font.family: "Nokia Pure Text"
textFormat: Text.AutoText
wrapMode: Text.Wrap
}
Text {
id: companyInfo
anchors.top: companyName.bottom
text: modelData.companyInfo
x: 15; font.pixelSize: 16; anchors.topMargin: 5
textFormat: Text.AutoText
wrapMode: Text.Wrap
}
Text {
id: duration
anchors.top: companyInfo.bottom
text: modelData.startDate + " - " + modelData.endDate
x: 15; font.pixelSize: 20; anchors.topMargin: 5
textFormat: Text.AutoText
wrapMode: Text.Wrap
}
Text {
id: positionSummary
anchors.verticalCenter: parent.verticalCenter
x: 15; width: 455; anchors.topMargin: 5
font.pixelSize: 20
text: modelData.positionSummary
anchors.top: duration.bottom
textFormat: Text.AutoText
wrapMode: Text.Wrap
anchors.bottomMargin: 5
}
MouseArea {
anchors.fill: parent
onClicked: {
console.log (parent.height);
}
}
}
}
More information about the Qt-qml
mailing list