PDA

View Full Version : how to redraw cube to rectangle



wagmare
10th February 2009, 12:26
hi friends/experts,
i attach a .png image which i like to draw on screen on QGraphicsView as an Item ...
is it possible to animate it as if user mouse press this will repaint reducing to rectangle and release will take it to original form as like padnavigator example item which expands and contract ...
can any one please give me some useful suggestion as it is able work or not and how can i do that as erasing the lower part of the area on timeline forward and redrawing in timeline backward ...
please suggest me how can i plan this ...

Lykurg
10th February 2009, 13:19
Hi,

private member bool isDown in your item, listening to mouse press/release event -> changing isDown and call update. In your paint directive handle isDown.

Lykurg

wagmare
10th February 2009, 13:45
thanks for the reply first:)


Hi,

private member bool isDown in your item, listening to mouse press/release event -> changing isDown and call update. In your paint directive handle isDown.

Lykurg

This property holds whether the button is pressed down.
but i am not using a button i am using a painted cube ... as an item ...

Lykurg
10th February 2009, 13:52
Hi,

what I meant was to create a private variable named xyz (and also it could be named isDown).


...
private:
bool xyz;

YourItem::mousePressEvent(...)
{
xyz = true;
update();
}

YourItem::mouseReleaseEvent(...)
{
xyz = false;
update();
}

YourItem::paint(...)
{
if (xyz)
...//draw flat
else
...//draw 3d
}

wagmare
10th February 2009, 14:01
thanks now i got it ...
and how can i erase the side portion of an item like the cube pressed in timeline signals is there any option in QpaintEvent to erase the particular render area and redraw

Lykurg
10th February 2009, 14:35
There my deeper knowledge is gone, but I think that to handle erase etc for such an easy item (as shown in the attached image) is to much. Just draw the entire item in the paint-method depending on the state. At the beginning of paint() Qt deletes all previous content by default. That is - as I guess - better in performance than to erase (and then you surely want to move the blue rect...).

Lykurg

wagmare
11th February 2009, 05:26
hahaha ... i just ask is there any possiblity ..thanks i will do the same .. i just move the blue item using translate so it will overdraw the below lines ..