Results 1 to 4 of 4

Thread: Qt Zoom

  1. #1
    Join Date
    Mar 2008
    Posts
    68
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Qt Zoom

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt Zoom

    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:
    Qt Code:
    1. QPainter painter(this);
    2. painter.save(); // save the state of the painter before scaling
    3. painter.scale(...);
    4. painter.drawSomething(...); // draw something as scaled
    5. painter.restore(); // restore the state back to before scaling
    6. painter.drawText(...); // draw text unscaled
    To copy to clipboard, switch view to plain text mode 
    PS. Graphics view framework would have QGraphicsItem::ItemIgnoresTransformations...
    J-P Nurmi

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt Zoom

    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 ..

  4. #4
    Join Date
    Apr 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Angry Re: Qt Zoom

    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.
    "A fool can ask More questions that a wise man cannot answer"
    /home/nithyanair/Pics/image.jpg

Similar Threads

  1. how to zoom out item in View/Scene
    By nileshsince1980 in forum Qt Programming
    Replies: 7
    Last Post: 28th December 2007, 10:24
  2. RubberBand zoom implementation for images
    By cdemirkir in forum Qt Programming
    Replies: 4
    Last Post: 16th July 2007, 22:55
  3. Replies: 2
    Last Post: 21st May 2007, 21:12
  4. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34
  5. Zoom Options
    By Kapil in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 11:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.