[Qt-interest] drag and drop of standard Qt's widgets
George Brink
siberianowl at yahoo.com
Wed May 11 18:12:40 CEST 2011
On 5/11/2011 1:14 AM, Bo Thorsen wrote:
> Den 10-05-2011 16:26, George Brink skrev:
>> I would like to DnD an item from a QTreeWidget into another widget (in
>> the same application.
>> The "drag" part of DnD works perfectly, but I do not understand how to
>> extract the dragged QTreeWidgetItem from the QMimeData object?
>> -------------------
>> void MyWindow::dropEvent(QDropEvent *e) {
>> if( e->mimeData()->hasFormat(
>> "application/x-qabstractitemmodeldatalist")) {
>>
>> QByteArray ba = e->mimeData()->data(
>> "application/x-qabstractitemmodeldatalist");
>> QTreeWidgetItem twi = ba; // ???? how?
>>
>> qDebug()<< twi.text(0);
>> e->acceptProposedAction();
>> }
>> }
>> -------------------
>> Where is the manual which describes relationship between Qt's widgets
>> and QMimeData?
>
> You have this slightly wrong. A widget isn't drag'n'dropped, the
> contents are. So the drop contains what the treeitem contains. If you
> want to control what's dragged, you can do this from the tree model.
>
> The widget can't be dragged because widget objects can't be copied.
>
> Bo Thorsen,
> Fionia Software.
>
Ok, "application/x-qabstractitemmodeldatalist" is not a widget, it is an
object. But my question remains: how to decipher it from QByteArray form
into something usable?
More information about the Qt-interest-old
mailing list