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?
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.
Re: QGraphicsItem selectable and also draggable
It works!
Thanks for the suggestions too, I will follow them.