Results 1 to 20 of 32

Thread: Zooming scene Rect(Qt bug?)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Smile Re: Zooming scene Rect(Qt bug?)

    maverick_pol, please just send a compilable self-contained example, and the bug is likely to be revealed right away. It's hard to debug code that's translated to english.
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  2. #2
    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: Zooming scene Rect(Qt bug?)

    Hi,

    I can't send you the code as I do not have permision to do so. I will send the (rectangle/size/etc) within 15 minutes.

    Here it is:

    The code I am using to print values:
    Qt Code:
    1. // the given _rectangle for zooming
    2. qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
    3. qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
    4. qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
    5. qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
    6. m_view->fitInView(_rectangle,Qt::KeepAspectRatio); // or Qt::KeepAspectRatioBy expanding
    7. // Scene rectangle
    8. _rectangle = m_view->sceneRect(); qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
    9. qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
    10. qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
    11. qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
    12. // scene rectangle(from view)
    13. _rectangle = m_scene->sceneRect(); qDebug()<<(_rectangle.bottomLeft().rx())<<(_rectangle.bottomLeft().ry());
    14. qDebug()<<(_rectangle.bottomRight().rx())<<(_rectangle.bottomRight().ry());
    15. qDebug()<<(_rectangle.topLeft().rx())<<(_rectangle.topLeft().ry());
    16. qDebug()<<(_rectangle.topRight().rx())<<(_rectangle.topRight().ry());
    17. // view size
    18. qDebug()<<m_view->size().height()<<m_view->size().width();
    19. //view matrix
    20. qDebug()<<m_view->matrix().m11()<<m_view->matrix().m12()<<m_view->matrix().m21()<<m_view->matrix().m22()<<m_view->matrix().det()<<m_view->matrix().dx()<<m_view->matrix().dy();
    To copy to clipboard, switch view to plain text mode 

    HEre is the result:

    -172 38
    78 38
    -172 -112
    78 -112
    -50 80
    50 80
    -50 50
    50 50
    -50 80
    50 80
    -50 50
    50 50
    660 1224
    4.34667 0 0 4.34667 18.8935 0 0

    QGraphicsScene::removeItem: item 01F45440's scene (00000000) is different from this scene (01AB88D8)

    -51.3037 67.408
    11.1963 67.408
    -51.3037 29.908
    11.1963 29.908
    -50 80
    50 80
    -50 50
    50 50
    -50 80
    50 80
    -50 50
    50 50
    660 1224
    17.3867 0 0 17.3867 302.296 0 0

    QGraphicsScene::removeItem: item 01E9E968's scene (00000000) is different from this scene (01AB88D8)

    -30.8857 57.2278
    -15.2607 57.2278
    -30.8857 47.8528
    -15.2607 47.8528
    -50 80
    50 80
    -50 50
    50 50
    -50 80
    50 80
    -50 50
    50 50
    660 1224
    67.84 0 0 67.84 4602.27 0 0

    QGraphicsScene::removeItem: item 01F78660's scene (00000000) is different from this scene (01AB88D8)

    -19.487 52.5501
    -15.5808 52.5501
    -19.487 50.2064
    -15.5808 50.2064
    -50 80
    50 80
    -50 50
    50 50
    -50 80
    50 80
    -50 50
    50 50
    660 1224
    271.36 0 0 271.36 73636.2 0 0

    I have used zoom In 4 times here and after the second Zoom IN my widgets(created with m_view->viewport() as the parent) moved left. I tried to recreate the widgets after zooming In (removing items and addint them once again) that's why I get the "removeITem" warning.

    Maverick
    Last edited by maverick_pol; 21st August 2007 at 13:01.
    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

  3. #3
    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: Zooming scene Rect(Qt bug?)

    Looks like I was right from the very beginning - scene coordinates seem incorrect.

    BTW. You could have formatted the output better, you know...

  4. #4
    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: Zooming scene Rect(Qt bug?)

    Hi,

    I will format the INPUT correctly. Sound good that you were right, but I still do not know what is the problem. Could you explain it to me?
    When I use (scale() and fitInView() ) function the coordinates system changes, what kind of incorrectness you're seeing here?
    I really appreciate your help in this thread.

    Maverick
    Last edited by maverick_pol; 21st August 2007 at 13:45.
    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

  5. #5
    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: Zooming scene Rect(Qt bug?)

    Take a look at the coordinates of the zooming rect, the scene and the view during first two zooms. If you have trouble, take a piece of paper and draw the rectangles, taking a closer look at how they intersect each other. Only during the last two sets of coordinates the zooming rectangle is smaller than the scene. A nice thing to have would be to know the bounding rect of all the items in the scene as well...

    You should really try with a minimal compilable example as asked at the beginning... Or provide actual code - we won't steal it

  6. The following user says thank you to wysota for this useful post:

    maverick_pol (22nd August 2007)

  7. #6
    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: Zooming scene Rect(Qt bug?)

    Hi,

    Here is the piece of code I am using ( it's 100% what I have in my application(the part connected with gview framework).
    After choosing the Zoom in from the Context menu and once again clicking left mouse button the rectangle appears and can be moved with the cursor and resized while pressing the right mouse button.
    (There are 2 windows, the one with the gview is mine; other is not used)

    My "Panels"(in the fungc class) should be at the same place while zooming, but are moving.
    also in the begining(while zooming for first 2...4 times the center of the scene is zoomed not the rectangle).

    If you have any ideas I would appreciate your help.

    P.S. I have compiled/run this code using Qt 4.3.1 under win32

    Maverick
    Attached Files Attached Files
    Last edited by maverick_pol; 22nd August 2007 at 09:57.
    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

  8. #7
    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: Zooming scene Rect(Qt bug?)

    Hi guys,

    Any ideas what can be the problem?(wrong zooming rectangle and moving Panels(labels))

    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

  9. #8
    Join Date
    Nov 2006
    Location
    Shrewsbury, UK
    Posts
    97
    Thanks
    3
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Zooming scene Rect(Qt bug?)

    I'm not really a QGraphicsView expert and I've only got 4.2.1 at work so I had to hack out some of the hints, but you might find that the odd "update();" at the end of your zoomin, zoomout and mousemove routines might help a bit.

    Pete

  10. #9
    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: Zooming scene Rect(Qt bug?)

    all ideas are usefull.

    I will try using "update()" and give you the result, but this probably will not solve all the problems.

    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

Similar Threads

  1. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51
  2. Zooming scene
    By maverick_pol in forum Qt Programming
    Replies: 12
    Last Post: 2nd August 2007, 17:37
  3. How to use QGraphicsView and Scene right ...
    By Mike in forum Qt Programming
    Replies: 6
    Last Post: 22nd January 2007, 08:51

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.