[Qt-interest] Drag and Drop Pointers/QModelIndex Within Application

Karol Krizka kkrizka at gmail.com
Mon May 25 11:12:00 CEST 2009


Hi there,

I'm basically trying to add a DnD interface to my application. I do not
need to be able to drag/drop outside of the application.

I basically have a list of categories, each with a set of items
organizes in a tree (QTreeView). I want to be able to move the items
between the categories by dragging and dropping them. I thought the best
idea would be to pass the QModelIndex of the items being dragged in the
DnD event and then in the dropAction, I would figure out where the index
came from and where it was dropped, then perform the move. Another idea
was that I pass the pointer to the item.

However, the data for a DnD event seems to be passed via the QMimeData
structure, which only supports data in the format of color, string, html
or a bytestream.

So, what is the best way to pass data using DnD inside an application?

--
Cheers,
Karol Krizka
http://www.krizka.net




More information about the Qt-interest-old mailing list