Results 1 to 4 of 4

Thread: Get informed when the scene is moved with QGraphicsView ScrollHandDrag drag mode

  1. #1
    Join Date
    May 2009
    Posts
    21
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Get informed when the scene is moved with QGraphicsView ScrollHandDrag drag mode

    Hi,

    I'm using the QGraphicsView dragMode ScrollHandDrag to move the visible part of the scene within my view by mouse dragging. Now I need a means to find out the new scene position at the center point of the view after such a move each time the scene has been moved. Is there any way to get informed when the scene has been moved by ScrollHandDrag?

    Thanks

    Lodorot

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

    Default Re: Get informed when the scene is moved with QGraphicsView ScrollHandDrag drag mode

    I would reimplement QGraphicsView::scrollContentsBy() in a subclass of QGraphicsView and fish out the deltas. Or connect to the scrollbars to find when the scroll bar values have changed.
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  3. #3
    Join Date
    May 2009
    Posts
    21
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get informed when the scene is moved with QGraphicsView ScrollHandDrag drag mode

    I hoped there would be a way without subclassing QGraphicsView.

    I tried to connect to the scrollbars but the problem is I never know when the moving is finished. The dragging is done by scrolling. First the horizontalScrollBar is changed than the verticalScrollBar. But the scrollbar only signal if their values actually have been changed. So the dragging can stop with a horizontal or a vertical scrolling signal.

    Regards

    Lodorot

  4. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Get informed when the scene is moved with QGraphicsView ScrollHandDrag drag mode

    What about creating a QPoint(yourView.width()/2, yourView.height/2) and feeding it to mapToScene()?

Similar Threads

  1. Painting problem when QMdiSubWindow is moved over QGraphicsView
    By Jayakrishnan in forum Qt Programming
    Replies: 0
    Last Post: 19th February 2010, 07:51
  2. QGraphicsview RubberBand Drag Mode
    By gopikrishnav in forum Qt Programming
    Replies: 0
    Last Post: 14th December 2009, 06:37
  3. Replies: 1
    Last Post: 12th October 2009, 12:26
  4. adding QGraphicsSvgItem to scene, drag and drop?
    By abhilashm86 in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2009, 16:05
  5. Replies: 9
    Last Post: 12th March 2009, 16:19

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
  •  
Qt is a trademark of The Qt Company.