[Development] Drag and Drop: Leave instead of Drop

Cyril Oblikov munknex at gmail.com
Thu Aug 15 08:59:22 CEST 2013

14 авг. 2013 г. 21:59 пользователь "Sven Putze" <
mailinglist.Qt-creator at hardcodes.de> написал:
> Hi,
> do you accept the event for the top level window? Then this would explain
why you/the user can see the "accepting" cursor everywhere.
> I would suggest to accept (and handle) the event per widget/drop area.

Ok, let me explain again. I need to know when items are dragged over my
app. So I need to know:

1. When dragged items enters my app. MainWindow::dragEnterEvent()

2. When dragged items leave my app. MainWindow::dragLeaveEvent(). But
handler is only activated when QDragEnterEvent was accepted previously. I
accept it and set accepted actions to Qt::IgnoreActon so user see
"forbidden" cursor. To make sure that items really no longer inside my app,
I check if QCursor::pos() is outside.

3. When items are dropped on widget supporting drop. Pretty easy, just use

4. When dragged items are dropped inside my app, but on place which doesn't
support drop. And here is a problem: MainWindow::dropEvent() is not called
if acceptedActions is set to Qt::IgnoreActon. So I get
MainWindow::dragLeaveEvent() instead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130815/221204a7/attachment.html>

More information about the Development mailing list