Qt drag and drop between two QListWidget

I've two QListWidget (list1 and list2)

  • list1 should be able to receive items from list2
  • list1 should be able to be reorganized with an internal drag and drop
  • list2 should be able to receive items from list1

list1->setSelectionMode(QAbstractItemView::SingleSelection);
list1->setDragEnabled(true);
list1->setDragDropMode(QAbstractItemView::DragDrop);
list1->viewport()->setAcceptDrops(true);
list1->setDropIndicatorShown(true);

ulist2->setSelectionMode(QAbstractItemView::SingleSelection);
list2->setDragEnabled(true);
list2->setDragDropMode(QAbstractItemView::InternalMove);
list2->viewport()->setAcceptDrops(true);
list2->setDropIndicatorShown(true);

I had to put the list2 on InternalMove otherwise the item is not remove when I drag it to the list1.

And if i put list1 to InternalMove i can't drop any more on it.

Do I have to write my own drag and drop function to do that?

11
задан ismail 4 January 2011 в 14:41
поделиться