1 Attachment(s)
how to redraw cube to rectangle
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 ...
Re: how to redraw cube to rectangle
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
Re: how to redraw cube to rectangle
thanks for the reply first:)
Quote:
Originally Posted by
Lykurg
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 ...
Re: how to redraw cube to rectangle
Hi,
what I meant was to create a private variable named xyz (and also it could be named isDown).
Code:
...
private:
bool xyz;
YourItem::mousePressEvent(...)
{
xyz = true;
update();
}
YourItem::mouseReleaseEvent(...)
{
xyz = false;
update();
}
YourItem::paint(...)
{
if (xyz)
...//draw flat
else
...//draw 3d
}
Re: how to redraw cube to rectangle
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
Re: how to redraw cube to rectangle
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
Re: how to redraw cube to rectangle
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 ..