How to catch items dropped out of scenes?
If user takes item on scene - then I "take" it out. While user drags it - item flies over application in QDrag object. When user drops it somewhere outside reasonable scene - I need return item to initial position where it was taken. But I do not see how do that. Only one thing I found - QDrag emits targetChanged() signal when drag exits outside application. But I need catch DROP event outside app. How do that?? Sure entire event processing can be implemented in app but this does not look Qt-like. Is it a huge groove in Qt D&D engine or I just missed something?
Re: How to catch items dropped out of scenes?
If the drop doesn't work, the place where the drag starts should receive information about it as a result of QDrag::exec().
Re: How to catch items dropped out of scenes?
Quote:
Originally Posted by
wysota
If the drop doesn't work, the place where the drag starts should receive information about it as a result of
QDrag::exec().
And what? QDrag::exec() returns value of Qt::DropActions enum which is unusable in this case. And I call drag->exec(); in implementation of mouseMoveEvent(QGraphicsSceneMouseEvent *event) in draggable item but not in scene.
Re: How to catch items dropped out of scenes?
Quote:
Originally Posted by
Gourmet
Why? If Qt::IgnoreAction is returned then there was no drop.
Quote:
And I call drag->exec(); in implementation of mouseMoveEvent(QGraphicsSceneMouseEvent *event) in draggable item but not in scene.
I don't see how that matters.
Re: How to catch items dropped out of scenes?
Ok, this works. But looks not so... straight. I'd better prefer signal QDrag::droppedTo( QWidget*, QPointF );
Re: How to catch items dropped out of scenes?
That would be useless if the drop occurred outside your app. Or was canceled.
Re: How to catch items dropped out of scenes?
Otside the app QWidget* would be 0 with QPointF representing absolute screen position. This would be enough and easy to use.
Re: How to catch items dropped out of scenes?
Maybe in your particular case yes but I don't see what benefit it would bring to know the screen coordinates of the drop. Especially if more than one application window occupies the same screen spot. Basically it is the target application that handles the drop, the source should only know whether the semantics is to let go of the resource or not.