[Qt-interest] Changing order of items in QListWidget per Drag and drop

Oliver Demetz forenbeitraege at oliverdemetz.de
Wed Jun 3 10:36:44 CEST 2009


Hi!

I've got a QListWidget in IconMode and
I want to be able to drag the items
around and change their order.

Using this code this is *partly possible*

     list = new QListWidget;
     list->setViewMode(QListView::IconMode);
     list->setMovement(QListView::Snap);
     list->setDragDropMode(QAbstractItemView::InternalMove);

*BUT:* One can only move an item to a *free place*
with this code.

Example:
Two items per row and 5 items prensent in total:

  1 2
  3 4
  5

Now one only move an item to the sixth position, eg
item 2 to pos 6:

  1
  3 4
  5 2

It is *not possible* to drag item 2 between 3 and 4,
which should lead to the following situation

  1 3
  2 4
  5

How can I acchieve this?

Additionally, having a "move marker" like in the Windows Start menu
would be perfect (see attached image).

Best regards,
Oliver
-------------- next part --------------
A non-text attachment was scrubbed...
Name: move.png
Type: image/png
Size: 6219 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090603/411e49ef/attachment.png 


More information about the Qt-interest-old mailing list