[Qt-interest] QTableView Drag and Drop

Stephen Kelly steveire at gmail.com
Sun Nov 21 23:42:57 CET 2010


Alexander O. Anisimov wrote:
> [code]
>    QByteArray encodedData = data->data("application/vnd.text.list");
>     QDataStream stream(&encodedData, QIODevice::ReadOnly);
> 
>     while (!stream.atEnd())
>    {
>         QString first, second;
>        stream >> first >> second;
>         QPair <QString, QString> pair(first, second);
>        beginInsertRows(QModelIndex(), endRow, endRow);
>         listOfPairs.insert(endRow, pair);
>        endInsertRows();
>         endRow ++;
>    }
>     return true;
> }
> 
> [/code]
> 
> When I DnD some item from first table to second the item is copied into
> second table, but not removed from first table. Can you help me?
> 

I didn't read very closely, but you seem to insert the items here, though 
you never remove them from the source, so the copy is exactly what you 
coded. 

If using Qt 4.6 beginMoveRows/endMoveRows might help.

All the best,

Steve.




More information about the Qt-interest-old mailing list