[SOLVED]Negative height and ListView background
-
Hello all!
I've found that if I use negative height(e.g. for Rectangle) then I have my rectangle mirrored against its start point i.e it grows in the reverse direction. And I need to know: can I expect this behaviour all the time further or it can be changed somewhen in the future? The question appeared due to a lack of any mentions about a negative height in the docs.
-
mbrasser, thank you for explanation. Unfortunately I didn't find another way to accomplish my goal without this "concealed feature".
Maybe I missed something and you would suggest me something? I need to draw rectangles on the ListView element field i.e. create background for it. Currently I do it by using footer property and mirroring rectangle because in normal situation footer rectangle grows outside ListView field but I need to fill inside space. -
[quote author="ixSci" date="1296543507"]Maybe I missed something and you would suggest me something? I need to draw rectangles on the ListView element field i.e. create background for it. Currently I do it by using footer property and mirroring rectangle because in normal situation footer rectangle grows outside ListView field but I need to fill inside space. [/quote]
I'm having a hard time visualizing this -- do you have a small mockup showing what you mean?
Regards,
Michael -
!http://img202.imageshack.us/img202/1920/listviewo.png(listview)!
You can see bars and lines behind the bars. Those lines are rectangles which I draw via footer and negative height. Bars are ListView delegates.
Foot scale is a part of the footer too. -
[quote author="ixSci" date="1296661041"]2beers, good point. But it will end up in the same question but for y property. Because it will be negative then[/quote]
I don't think there will be a problem with a negative coordinate in future releases, maybe we get some official response, however you can achieve this if you want. you sttart painting from 0,0 coordinates.
Again I don't think there will be a problem with negative coordinates in future release, but I'm not the right person to give such guarantees.
-
Hi,
You should be able to get the same effect with either a child or sibling of the ListView. For example:
@import QtQuick 1.0
Rectangle {
width: 400
height: 400//option 1 (sibling) Row { x: -1; y: -1 Repeater { model: 4 delegate: Rectangle { width: 100; height: view.height+1 border.width: 1 color: "#cccccc" } } } ListView { id: view anchors.fill: parent model: 100 delegate: Item { width: 400; height: 50 Rectangle { color: "green" height: 25 width: Math.random() * 401 anchors.verticalCenter: parent.verticalCenter } } //option 2 (child) /*children: Row { z: -1 x: -1; y: -1 Repeater { model: 4 delegate: Rectangle { width: 100; height: view.height+1 border.width: 1 color: "#cccccc" } } }*/ }
}@
Does something like this work for your case?
Regards,
Michael