PDA

View Full Version : Qt Zoom



csvivek
26th May 2008, 17:01
I have a Widget on which i draw some text and some objects.
now when i click zoom. i am increasing the scale factor of the widget to certain value.
My requirement is that when i zoom the text should be of the same size while the objects should be scaled to the corresponding zoom factor.
But the text also gets scaled.
how do i restrict the size of the text drawn to be of the same size for different scale factors while increasing the size of other objects drawn on the widget to corresponding scale factors?
I Use paintEvent to Draw all these objects.

jpn
26th May 2008, 17:09
Then make sure the painter is in unscaled state when you draw the text. Either draw the text before scaling or do something like this:


QPainter painter(this);
painter.save(); // save the state of the painter before scaling
painter.scale(...);
painter.drawSomething(...); // draw something as scaled
painter.restore(); // restore the state back to before scaling
painter.drawText(...); // draw text unscaled

PS. Graphics view framework (http://doc.trolltech.com/4.4/graphicsview.html) would have QGraphicsItem::ItemIgnoresTransformations...

patrik08
26th May 2008, 19:38
PS:
on German forum http://www.qtforum.de/forum/viewtopic.php?t=6774
you find 2 attachment file

qpush1.cpp
qpush1.h

it simple draw text as QPainterPath &

painter->setWindow ( 0 , 0 , reo.width() + (borderI * 2), reo.height() + (borderI * 2) );
having forever QRect from avaiable text. + border/padding

is a push button which is draw Vector elastic ... on event resize text become automatic the maximum enabled space like zoom

PS:
:( My Attachment quota on this forum is /dev/null and i not know how to delete Attachment.... I can not upload 1KB ..

Nithya
6th August 2008, 12:25
instead of using scale() function, resize the device on which u r drawing
e.g drawing on a paintdevice 100*100 , for zooming it twice make that to 200*200 and make all the drawing with twice the co-ordinates and width and write text on it.


here since the pixels are not doubled(what it do in scale), the text will be viewed in its size.:D