Results 1 to 1 of 1

Thread: Qgraphicsitem grabbed with mouse.

  1. #1
    Join Date
    Jul 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Qgraphicsitem grabbed with mouse.

    Hi all,
    I need to know in mouseMoveEvent of the scene class (derived from QGraphicsScene) if i'm currently moving an item in the scene.

    Items have flag ItemIsMovable but this flag is not always enabled because if the user click and drag in a particular spot of items i need to do something else and not moving the item.

    The only way i can accomplish this work is:

    -in mousePressEvent of item set a flag
    item_grabbed_for_moving=true if the user click everywhere in items
    item_grabbed_for_moving=false if the user click in that particular spot in the items

    -in mouseReleaseEvent of items
    item_grabbed_for_moving=false;

    -in mouseMoveEvent of Scene check if:
    mouseGrabberItem() has item_grabbed_for_moving==true.
    Qt Code:
    1. QGraphicsItem* t=mouseGrabberItem();
    2. if(t && t->type()==soa_item::Type && ((soa_item*)t)->IsItemMoving()){
    3. qDebug("You are currently moving a soa_item.");
    4. }
    To copy to clipboard, switch view to plain text mode 

    I think this is a bad way and i want to ask you if there is another,more clean, way to do this.

    Thx for answer.
    bye
    Last edited by repka3; 31st August 2009 at 15:47.

Similar Threads

  1. QGraphicsItem no mouse events called
    By munna in forum Qt Programming
    Replies: 11
    Last Post: 9th December 2009, 15:43
  2. Replies: 1
    Last Post: 16th July 2009, 17:58
  3. QGraphicsItem mouse out of focus
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 25th June 2009, 12:45
  4. how to prevent qgraphicsitem repaint while mouse move on it
    By christina123y in forum Qt Programming
    Replies: 22
    Last Post: 17th April 2009, 11:17
  5. Replies: 9
    Last Post: 22nd June 2008, 23:26

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.