Page 2 of 2 FirstFirst 12
Results 21 to 32 of 32

Thread: Zooming scene Rect(Qt bug?)

  1. #21
    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

  2. #22
    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

  3. #23
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Looking for a solution for over a week...can't find it ;((GraphicsView)

    Quote Originally Posted by maverick_pol View Post
    Excuse me for writing again about this problem, but the (my)last thread seems to die.
    Please don't start more than one thread on the same topic.

  4. The following user says thank you to jacek for this useful post:

    maverick_pol (24th August 2007)

  5. #24
    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?)

    Sorry. I should rather try to "refresh" the thread.

    using "update()", does not give any improvement.
    Still looking for a solution. Ideas appreciated.

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

    Alright, I gave it a try but I'm sorry to say I soon gave up. A couple of clear errors:
    • a QGraphicsView object allocated on the stack is being deleted => crash
    • a QGraphicsView* is incorrectly casted as GView*, an actual GView is never created (once you add a member to GView and try to call it => crash)

    Other comments:
    I'm not saying any of these particular issues would cause the misfunctionality, but things like public variables and first setting QGraphicsScene::NoIndex in GScene constructor but then switching it immediately to QGraphicsScene::BspTreeIndex in FundGC just make it hard to follow what is being modified and where, and who controls what. Sorry, but the attached code is a bit too "bloated" for an outsider to quickly see what's going on.
    J-P Nurmi

  7. #26
    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?)

    Ok, I will correct the mistaked right away.
    But do you have ideas why the zooming is wrong ?

    I understand that the code may not be as clear and high quality as at your level of coding, but I would like you, if it is not a problem, to look at 2 methods.

    fundgc.cpp ->FundGC::vZoomSceneRectangle(QRectF _rectangle);
    scene.cpp ->GScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent );

    mousePressEvent passes the rectangle for zooming(
    Qt Code:
    1. emit vSignalZoomRectangle(m_zoomPolygonItem->boundingRect());
    To copy to clipboard, switch view to plain text mode 
    and the vZoom... zooms the rectangle. There is an error in the this methods or scene settings, which I can't find on my own.

    A -> base class
    B: public A

    dynamic_cast<B*>(A*) <- why this casting will not work? ( or static)

    I really appreciate your help and ideas.

    Maverick
    Last edited by maverick_pol; 24th August 2007 at 13:24.
    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. #27
    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 have na idea where the problem lays(I suppose that wysote suggested it at the beginning in the first place, but didn't understand the idea). I belive the problem is connected with scene/view sizes.
    Here is the information about the view/scene sizes after construction and their sizes while doing the first zooming.

    Just after construction:
    Qt Code:
    1. qDebug()<<m_view->size().height()<<m_view->size().width();
    2. m_scene->setSceneRect(-50,50,m_view->width(),m_view->height());
    3. qDebug()<<m_scene->sceneRect().height()<<m_scene->sceneRect().width();
    To copy to clipboard, switch view to plain text mode 

    100 30
    100 30
    Before doing the first zooming :
    Qt Code:
    1. qDebug()<<m_view->size().height()<<m_view->size().width();
    2. qDebug()<<m_scene->sceneRect().height()<<m_scene->sceneRect().width();
    To copy to clipboard, switch view to plain text mode 

    660 1224
    100 30
    I would like to have the same coordinate system in the scene and the view. It looks like because of the scene/view size different the zooming is incorrect. Am I right?

    Because the first zooming rectangle(from my example zooming) has coordinates:
    -285 157
    215 157
    -285 -143
    215 -143
    and it's bigger than the scene, so I zoom the whole(the center).
    Ok...I belive this is the problem, but yet do not know how to fix it ?

    Any help appreciated.


    Maverick
    Last edited by maverick_pol; 25th August 2007 at 13:04.
    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. #28
    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?)

    You are creating the scene before the view is first shown. It such situation you can't rely on the view size, thus such small size of the scene. This probably causes the problem - when you zoom enough, the scene will become bigger than the view (after the transformation), causing the zoom to really happen (with wrong parameters, of course).

    And that's what I was saying from the very beginning...

    BTW. Try doing:
    Qt Code:
    1. qDebug() << QSize(20, 20);
    To copy to clipboard, switch view to plain text mode 
    You don't have to break QSize (and other value based Qt classes) to lowlevel bits like width and height when passing them to qDebug - they'll be printed correctly without that. It simplifies debugging structures very much, you should try it.

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

    maverick_pol (28th August 2007)

  11. #29
    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,

    Yes I do agree that your hints were correct:
    And that's what I was saying from the very beginning...
    I see that in my code I have to methods, and firstly I set the scene rect(using mview attributes) and then when I show the view(at my window is maximized view size changes, but not the scene coordinate system).

    Thank you for the idea:
    You don't have to break QSize (and other value based Qt classes) to lowlevel bits like width and height when passing them to qDebug - they'll be printed correctly without that. It simplifies debugging structures very much, you should try it.
    I will test it righ away and try to fix the zooming problem.

    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

  12. #30
    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?)

    Ok the problem is clear, but can't really get what I want.
    During construction view size is (30,100). Then after maximixing (660,1224).
    I can't set m-scene rectangle as (30,100) because after maximizing the coordinates are wrong. I tried setting the scene rectangle to (660,1224), but than the scene is much bigger than the viewport. My scene should always be the same size as the viewport, have the same coordinates system.

    Howto achieve this? I am trying to fix it, but still when zooming is Ok the scene is to big and I have to center is in the view.

    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

  13. #31
    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?)

    Ok, problem solved.

    I thank everyone, who helped me, especially wysota.

    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

  14. #32
    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?)

    So what was the solution?

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.