[SOLVED]Negative height and ListView background
-
wrote on 31 Jan 2011, 19:34 last edited by
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.
-
wrote on 31 Jan 2011, 23:18 last edited by
If you can find another method of accomplishing the same thing, I'd suggest doing that instead. It is unlikely to change in QtQuick 1.x, but may very likely change in QtQuick 2.0 (with the switch to the QML scenegraph).
Regards,
Michael -
wrote on 1 Feb 2011, 06:58 last edited by
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. -
wrote on 2 Feb 2011, 00:52 last edited by
[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 -
wrote on 2 Feb 2011, 11:58 last edited by
!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. -
wrote on 2 Feb 2011, 12:14 last edited by
not sure if this is what you're looking for but you can draw rectangles with positive height and change the x,y coordinates. I think it will have the same effect.
-
wrote on 2 Feb 2011, 15:37 last edited by
2beers, good point. But it will end up in the same question but for y property. Because it will be negative then
-
wrote on 2 Feb 2011, 15:43 last edited by
[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.
-
wrote on 2 Feb 2011, 17:55 last edited by
[quote author="2beers" date="1296661394"]
you sttart painting from 0,0 coordinates.
[/quote]
no, in a footer (0,0) is the bottom of a ListView instance -
wrote on 2 Feb 2011, 22:41 last edited by
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 -
wrote on 3 Feb 2011, 11:00 last edited by
mbrasser, both options are great! Thank you!
9/11