QtQuick and Drag-n-Drop

Implementing drag-n-drop (from now on DnD) in QtQuick is like traveling to an up-side-down world. Instead of dragging something and dropping it on a zone, the dragged item (or, rather, the MouseArea controlling the drag) is responsible for keeping track of where it is.

I’ve experimented with a few tricks to resolve this, and I believe that I’ve sorted the dragging half. The question is if I want to improve the receiving end. The concept is that you have a DragArea – which is just a fancy MouseArea. It has a property, zones, which is a list of QtObjects implementing methods to test if the zone is being hovered and to drop the item on the zone. This makes it possible for me to re-align the world with my brain, where the zones accepting the drops are playing an active role in the DnD.

Still, I have to think a bit about how to simplify the zones. Preferably, I’d like to be able to have a DropZone item that does all the fancy things and just lets the end-user (erhm, QtQuick developer, that is), indicate if the item can be dropped and then handle the onItemDropped event. Will see if I have time to polish this over Christmas.

By the way, the new Qt docs really confuse me. Could someone please reduce all the fancy effects, like having to expand each method to see the details. Also, having the Detailed Description on the top kind of reduces the need for a brief. It also slows down my average use-case, i.e. go to the page of a class, pick a method, click it and read. If I want details, I could go to the page of a class, click more and read. To get to the methods in the new layout, I have to scroll for a while, how much depends on the class, then click the item. Also, sending links to the details of specific methods is no longer readable.

This entry was posted in Miscellaneous, Qt. Bookmark the permalink. Both comments and trackbacks are currently closed.

6 Comments

  1. Jérémie Delaitre
    Posted 2011-12-21 at 15:10 | Permalink

    DnD in QtQuick is really a pity. Any improvement in this area will be very appreciated here :)

    A simple use case I had few months back is two lists with the ability to drag and drop items from one to another, and to re-arrange the items inside a list. I succeeded to implement it but it was REALLY hackish.

  2. Posted 2011-12-21 at 15:12 | Permalink

    Just dragging items from lists (or any type of itemview) is what my DragArea does. It looks a bit like a hack, but I have been able to reduce the code duplication quite dramatically.

    My use case is that I have a number of lists with various search results presented in various ways. These results can then be dropped onto a range of zones, be it simple activation zones or into lists where they are inserted.

  3. illissius
    Posted 2011-12-21 at 15:24 | Permalink

    I agree: the design of the Qt documentation has been a steady march of improvement over the past several releases, until the inexplicable backslide with 4.8.

  4. Antti
    Posted 2011-12-21 at 19:38 | Permalink

    Yes, the new documentation is definitely a big let-down in usability. It’s much harder to get to the relevant information, the layout/markup is not as readable as previously, and some parts are altogether missing: for an example of the missing info, try to google for qChecksum. You get the QByteArray page, but the actual “Related Non-Members” part is nowhere to be found.

    Sorry for a bit offtopic rant :)

  5. Posted 2011-12-22 at 11:19 | Permalink

    That’s another thing we have already been working on in the Plasma team.

    Bugs me a bit that there’s different efforts to solve the same problem, this might point us right at a lack of communication…

  6. Posted 2011-12-22 at 11:22 | Permalink

    @sebas I know – Marco Martin mailed and told me – I will follow-up in a blog later today. In the mean time, the big difference seems to be that I’ve approached the problem with a QML-only solution, while you guys need to support a multi-process world with drops from other processes.

  • December 2011
    M T W T F S S
    « Nov   Jan »
     1234
    567891011
    12131415161718
    19202122232425
    262728293031