[Development] QML DropArea documentation unhelpful

Ben Lau xbenlau at gmail.com
Wed May 14 22:44:34 CEST 2014


well , I also think that the document about Drag and Drop is not clear
enough.. Reading from example code is more easy to understand.

Anyway , the solution to your problem: You should call drag.accept() within
the onEntered slot. Then it will enable the onDropped slot to be executed.

http://qt-project.org/doc/qt-5/qml-qtquick-dragevent.html#accept-method




On 15 May 2014 04:04, Kevin Funk <kfunk at kde.org> wrote:

> Hey,
>
> I'm trying to get my head around the QML Drag and Drop API and keep finding
> oddities. (I've already posted some bugs and CRs in order to improve the
> situation). But here's a new one:
>
> DropArea has a 'onDropped' signal, that is supposed to be emitted "when a
> drop
> event occurs within the bounds of a a DropArea." [1]. Great. In good faith,
> I've added a DropArea to my Item, implemented DropArea.onDropped and
> presumed
> that this handler would be called as soon as I drop something on it (using
> a
> drag-enabled item).
>
> Now, that's not the case:
> DropArea.onEntered is called, but never DropArea.onDropped.
>
> This is *very* confusing for the first time user.
>
> [2] suggests adding something like this to the MouseArea initiating the
> drag:
>
>   onReleased: {
>     root.Drag.drop()
>   }
>
> That will work, but it looks really more like a crude hack. Digging through
> the source code, it seems that DropArea.onDropped is only called in case of
> "external drop" events. The 'externaldraganddrop' example is also the only
> user of that handler.
>
> However, I believe we should try calling DropArea.onDropped in all cases --
> without the work-around from above.
>
> Makes sense? If yes, I'll try to prepare a patch which addresses this.
> Happy
> to get any kind of feedback on this issue.
>
> Greets
>
> [1]
> http://qt-project.org/doc/qt-5/qml-qtquick-droparea.html#onDropped-signal
> [2]
> https://groups.google.com/forum/#!topic/qt-mailing-lists-qt-qml/rXiwqyp5Qk8
>
> --
> Kevin Funk
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140515/12d76b10/attachment.html>


More information about the Development mailing list