Results 1 to 4 of 4

Thread: Autoscrolling of QGraphicsView while moving a QGraphicsitem

  1. #1
    Join Date
    Sep 2011
    Location
    Mannheim, Germany
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Autoscrolling of QGraphicsView while moving a QGraphicsitem

    Hi,

    I am using a QGraphicsScene with some moveable QGraphicsItems. The scene is bigger than the view and screen.
    How can I enable autoscrolling of the view when the user moves an item near the screen border???

    Calling QGraphicsView::ensureVisible() in the MouseMoveEvent is not usefull solution, because it triggers always a vertical and horizontal scrollEvent.
    Even the user moves the mouse strictly horizontal.

    greets,
    Dennis

  2. #2
    Join Date
    Jun 2014
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Autoscrolling of QGraphicsView while moving a QGraphicsitem

    Dennis, you solved your problem? I have the same ...

  3. #3
    Join Date
    Sep 2011
    Posts
    37
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Autoscrolling of QGraphicsView while moving a QGraphicsitem

    In dragMoveEvent( QDragMoveEvent* e ) I detect if they are close to the edge of the viewport (you need to take account of the size of the scroll bars).

    If they are close to the top I scroll up.
    If they are close to the left side I scroll left.
    etc

    I use a timer so that it only scrolls every x milliseconds.

    HTH

  4. #4
    Join Date
    Jun 2014
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Autoscrolling of QGraphicsView while moving a QGraphicsitem

    The problem is, that I'm not using a drag-event. My item is not movable by QMouseEvent.

    Would you be please so kind and show me some snippet of your code?
    I appreciate your help.

Similar Threads

  1. Moving of QGraphicsItem
    By Erlendhg in forum Qt Programming
    Replies: 17
    Last Post: 5th November 2013, 15:04
  2. Moving child QGraphicsItem
    By roband915 in forum Qt Programming
    Replies: 0
    Last Post: 27th February 2011, 12:19
  3. Moving QGraphicsItem with mouse
    By BrainFreeze in forum Qt Programming
    Replies: 9
    Last Post: 11th February 2011, 00:48
  4. Update scene after moving QGraphicsItem
    By rogerholmes in forum Newbie
    Replies: 1
    Last Post: 19th January 2010, 05:08
  5. QGraphicsView: Moving multiple selection
    By marcel in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2007, 19:59

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.