Results 1 to 3 of 3

Thread: best way to detect when user stops moving a QGgraphicsItem

  1. #1
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default best way to detect when user stops moving a QGgraphicsItem

    I'm messing around with simple selectable + movable tiles in a graphics view/scene. When the user releases the LMB after dragging a Qgraphicsitem I want to invoke some actions.

    Do I have to sub-class the scene/item and watch mouse events to identify this?
    Last edited by amleto; 15th June 2013 at 14:41.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: best way to detect when user stops moving a QGgraphicsItem

    I am hard pressed to figure out how to retrieve the identity of a QGraphicsItem from a QGraphicsScene::dropEvent() if you install an event filter on the scene (or view). It looks like the best you can do is retrieve the coordinates from the event, then query the scene for the item at that location. It seems stupid if Qt makes you subclass all QGraphicsItem types just to handle drag / drop.

    Have you looked at the code for the elasticnodes example? Does that use drag / drop to move the nodes?

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: best way to detect when user stops moving a QGgraphicsItem

    I looked at that example - the moving of the nodes is just done with 'normal' graphics view implementation and there is no 'drop' notification anywhere.

    the example uses a Scene method ( QGraphicsItem *mouseGrabberItem() const; ) to identify when a node is being held by a user.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. QGraphicsItem Jerky Movement?
    By steadi in forum Newbie
    Replies: 0
    Last Post: 10th November 2012, 00:44
  2. Signals stops working
    By JaroMast in forum Qt Programming
    Replies: 4
    Last Post: 28th August 2012, 19:34
  3. Replies: 0
    Last Post: 24th May 2010, 12:19
  4. tab stops ?
    By ixM in forum Qt Programming
    Replies: 4
    Last Post: 28th May 2009, 13:11
  5. Replies: 2
    Last Post: 27th November 2008, 10:16

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.