[SOLVED] ListView with populate transition
-
Hello,
i try to create a ListView with a populate transition.
to keep it simple:
@
ListView {
anchors.fill: parent
model: ListModel {
id: modelData
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
}
delegate: Rectangle {
height: 44
width: 200
opacity: 0
Text {
anchors.centerIn: parent
text: name
}
}
populate: Transition {
NumberAnimation { property: "opacity"; to: 1.0; duration: 1000 }
}
}
}
@So what's happen here is all my items are at position 0,0. It doesn't madder what kind of Animation i did. All items are on the same position. Someone an idea?
-
Hi,
Are you using Window component as root element ? I too had came across this issue earlier and ended up using Item instead of Window.
-
First, Thx for your reply. I'm don't rely understand what u mean because i had an qt quick application so i need th Application Window as root?
Here my Full source.@
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")Rectangle { anchors.fill: parent color: '#ff0000' ListView { anchors.fill: parent model: ListModel { id: modelData ListElement { name: "Bill Smith" number: "555 3264" } ListElement { name: "John Brown" number: "555 8426" } ListElement { name: "Sam Wise" number: "555 0473" } } delegate: Rectangle { height: 44 width: 200 opacity: 0 Text { anchors.centerIn: parent text: name } } populate: Transition { NumberAnimation { property: "opacity"; to: 1.0; duration: 1000 } } } }
}
@ -
Ok.. That was a long time back. I usually use Item as root. Now after looking into this it seems that anchors.fill: parent for ListView is failing here. Try setting width and height to Rectangle or ListView.
Edited
-
Yes, it works but why??? Sounds totally stupid. It's a bug?
-
May be. It seems in that hierarchy ListView is not able to get the parent's width and height. Setting Width and Height to either one makes it work.
Edited previous post. -
The problem here set width and height make it difficult to automatically change size of the child. I know i can listen on onWidthChanged and onHeightChanged but the documentation always said "USE ACNHORS" :) so for me it's a but. I Fix it dirty. I initialize the Rectangle with a width and height and set in an Component.onComplete call the anchors.fill property. But it's a nasty workaround a think. I set the thread to solved because the main problem is solved.
THX for your help.