Results 1 to 3 of 3

Thread: QGraphicsItem selectable and also draggable

  1. #1
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsItem selectable and also draggable

    I have a QGraphicsItem descendant that has flag ItemIsSelectable set.
    Now I want to extend its behaviour allowing the user to drag and drop the item onto another item of the scene.
    To do this, I studied the dragdroprobot demo and I overrided
    mousePressEvent;
    mouseMoveEvent;
    mouseReleaseEvent;
    like shown in the demo sources.

    But, after this, the selection of the item is no more possible.

    What should I do to fix this issue and get the item selectable and also droppable?
    Is there any other demo or source that I could study?

  2. #2
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsItem selectable and also draggable

    Well once you override the functions mousePressEvent, mouseMoveEvent, mouseReleaseEvent the basic functionallity is disabled hence the problem of not beeing able to move it. So you also have to call the base implementation of these events.

    And if you are looking for drag and drop functions take a look at dragEnterEvent, dragMoveEvent and dragDropEvent.

    Just something to get you started.

  3. The following user says thank you to meazza for this useful post:

    corrado1972 (30th November 2011)

  4. #3
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsItem selectable and also draggable

    It works!
    Thanks for the suggestions too, I will follow them.

Similar Threads

  1. How to make an icon widget draggable
    By curiouswalker in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2010, 01:23
  2. Draggable QActions in Qt
    By vajindarladdad in forum Newbie
    Replies: 6
    Last Post: 14th August 2009, 11:15
  3. Implement draggable QWtplotmarker
    By shud in forum Qwt
    Replies: 3
    Last Post: 13th August 2009, 06:25
  4. QGraphicsItem point selectable "Problem in Zoom"
    By avis_phoenix in forum Qt Programming
    Replies: 0
    Last Post: 21st July 2009, 17:20
  5. Draggable Button
    By blueescort in forum Qt Programming
    Replies: 4
    Last Post: 6th November 2008, 07:36

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.