Results 1 to 4 of 4

Thread: Stop movement of QGraphicsItems on scene in ScrollHandDrag mode of QGraphicsView.

  1. #1
    Join Date
    Sep 2012
    Location
    Pune, India
    Posts
    18
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Stop movement of QGraphicsItems on scene in ScrollHandDrag mode of QGraphicsView.

    I have multiple QGraphicsItems in scene spread across different parts of scene. In application there are different modes in one of mode user can scroll the scene (palm drag mode).
    To achieve scrolling over scene I set dragMode of QGraphicsView to ScrollHandDrag.

    But the problem is when user try to scroll over scene by dragging (MousePress and MouseMove) on any of QGraphicsItem instead of scrolling scene it moves QGraphicsItem.


    How can I stop movement of QGraphicsItem and scroll the scene, but I still want to select QGraphicsItems?


    NOTE : There are very large number of QGraphicsItems and are of various type.
    So It is not possible to install event filter on QGraphicsItems.

  2. The following user says thank you to anwar.qt for this useful post:


  3. #2
    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: Stop movement of QGraphicsItems on scene in ScrollHandDrag mode of QGraphicsView.

    Reimplement mouse events for the view, only call the base class implementation if you want the items to be movable (i.e. when not in scroll mode). Alternatively while the drag is occuring, remove the unwanted flags (like movable, selectable) from the item under cursor. Just first make sure that a minimal example also reproduces your problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following 2 users say thank you to wysota for this useful post:

    anwar.qt (17th October 2012)

  5. #3
    Join Date
    Sep 2012
    Location
    Pune, India
    Posts
    18
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Stop movement of QGraphicsItems on scene in ScrollHandDrag mode of QGraphicsView.

    Thank You!! Solution Works.

  6. #4
    Join Date
    Sep 2012
    Location
    Pune, India
    Posts
    18
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Stop movement of QGraphicsItems on scene in ScrollHandDrag mode of QGraphicsView.

    I posted the same issue in an another forum. I got some useful replies. Click here to view.

    Setting QGraphicsView interactive to false works Fine!!

Similar Threads

  1. Replies: 1
    Last Post: 18th December 2011, 11:59
  2. Replies: 0
    Last Post: 29th December 2010, 16:10
  3. Delete QGraphicsItems from scene
    By Diph in forum Qt Programming
    Replies: 3
    Last Post: 17th April 2010, 15:00
  4. Replies: 3
    Last Post: 29th March 2010, 19:55
  5. Graphics item movement and scene bounds
    By Gianluca Magnani in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 09:02

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.