Results 1 to 3 of 3

Thread: qgraphicsview: how to keep fixed size of an item while zooming?

  1. #1
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qgraphicsview: how to keep fixed size of an item while zooming?

    I can't figure out to implement this scenario: I have a qgraficsscene populated with a ruler (qgrapchisitem) on the upper top of the scene, and other qgraphicsitems in the rest of the scene.
    When the user use the mouse wheel to perform a zoom-in/out, all the scene is scaled by the view,the ruler too. But I don't want that the ruler is scaled!
    I want to keep the rule at the same original size, without changing it's height and with. (intercepting the zooming signals, I will redraw the content of the ruler to appropriate scaling values).

    How can I solve this?


    Added after 1 3 minutes:


    Another thought: it I want that the ruler doesn't change its size, while the other items does, I will face the problem that other items will overlap the rule.
    One solution should be to put the ruler on another scene and the ruler view on the top of the items view:it has sense?
    Last edited by corrado1972; 18th February 2012 at 11:21.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qgraphicsview: how to keep fixed size of an item while zooming?

    I see two solutions. One, less proper, is to use ItemIgnoresTransformations flag on rules items. Second solution, more proper, is to not make the ruler an item but instead draw it manually outside the view's viewport(). The scene is your world. The ruler is not part of it so making it part of the scene is counter-intuitive.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qgraphicsview: how to keep fixed size of an item while zooming?

    Quote Originally Posted by wysota View Post
    The scene is your world. The ruler is not part of it so making it part of the scene is counter-intuitive.
    Thankyou wysota you helped me to understand that the ruler is not part of the items world!

Similar Threads

  1. Image rendering and zooming (QGraphicsView)
    By Sergex in forum Qt Programming
    Replies: 7
    Last Post: 6th October 2011, 13:51
  2. How to zooming like in AutoCAD with QGraphicsView?
    By Tarhan in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2011, 09:16
  3. Questions about zooming QGraphicsView
    By JovianGhost in forum Qt Programming
    Replies: 4
    Last Post: 30th March 2010, 15:54
  4. Zooming is too slow with QGraphicsView
    By learning_qt in forum Qt Programming
    Replies: 10
    Last Post: 4th December 2008, 10:23
  5. Zooming in QGraphicsView
    By JonathanForQT4 in forum Newbie
    Replies: 3
    Last Post: 17th April 2007, 06:50

Tags for this Thread

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.