Results 1 to 6 of 6

Thread: Ignoring zoomin/zoom out in the GraphicsView

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Ignoring zoomin/zoom out in the GraphicsView

    Hi guys,

    I have added a custom scene to the QGraphicsView object. Then I have create some items and added them to the scene. I do a lot of zooming in the graphicsview using:
    QGraphicsView::scale(...)

    This solution scales the whole QgraphicsView(changes the coordinate system, as you know). But I want my items not to change their sizes while zooming.

    How Can I create some items in the scene/view that are ignoring the scaling?

    Beforehand thanks.

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Ignoring zoomin/zoom out in the GraphicsView

    Use QGraphicsItem::setFlag(QGraphicsItem::ItemIgnoresT ransformations).

    Regards

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Ignoring zoomin/zoom out in the GraphicsView

    Hi,

    I have already used this solution. Items do not change their sizes, but while zoomin in/out as the xy coordinates change, items' position does the same. They move to the center(while zooming in)...etc

    Any other suggestions?

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Ignoring zoomin/zoom out in the GraphicsView

    But this seems normal behavior.
    If you really want fixed drawing, then do it in drawForeground or drawBackground for the view.

    Another way is to compute the scale factor and adjust the positions of the items you want fixed.

    Regards

  5. #5
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Ignoring zoomin/zoom out in the GraphicsView

    HI,

    Do you mean that, when I draw my "items" in the drawBackground/drawForeground of the QGraphicsView while zooming their position and size will not change? I was thinking about doing as you have said, but wasn't sure if it works..
    Have you tested this?

    Thank you for your reply and idea

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Ignoring zoomin/zoom out in the GraphicsView

    One simple way of doing it is...
    use QAbstractSlider::setTracking ( bool enable )... it wont emit the change in signal until u release the slider...
    Hope this will solve ur problem

Similar Threads

  1. Qt 4.2.3 Configure Issue...
    By amcdaniel in forum Installation and Deployment
    Replies: 4
    Last Post: 13th May 2007, 13:02
  2. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 06:23

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.