PDA

View Full Version : How to change the size of QGraphicsRectItem within HoverEvent()



ramfacts
3rd May 2010, 12:32
Hi,
i hav created a QGraphicsRectItem to be displayed when HoverEvent() called. its done well.

But, now i want to display that Rect Item with gradually opening effect.(ie. rect box grow like effect).
It's not work good. can u help me?
Ram.

Note: I m working in Qt 4.6.2 on Linux.:)

ramfacts
3rd May 2010, 12:38
In my code.

QTimeLine *timer = new QTimeLine(); //timer
timer->setFrameRange(0, 100);

QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
animation->setItem(rect); // rect is QGraphicsRectItem
animation->setTimeLine(timer);
animation->setScaleAt(1,2,2); //size of item is growing as well as item is moving too.
timer->start();
....

Here, size of item is growing as well as item is moving too.can i get the output without item is moved.?

ramfacts
3rd May 2010, 13:18
Here, x,y are the QGraphicsRectItem 's (x,y) element. &
r is a pointer to QGraphicsRectItem

for(float i = 1; i <= 100;i++){
r->setTransform(QTransform().translate(x, y).scale(i/100, i/100).translate(-x, -y));
}


may i know that this is correct?