Re-ordering QListWidget's items in IconMode



  • I want to use QListWidget to provide users an opportunity to re-order items with drag'n'drop technology. When QListWidget is in ListMode it's working fine. When I switch to IconMode, items are moved freely without autoarranging into single line. How can I use QListWidget for this task? Shoud I use another controls or model-based widgets?

    Sorry for my English.



  • Can you use QListView::Snap mode and set an appropriate grid size with setGridSize()?



  • When I use Snap mode and I set the grid size, items are snapped to the grid but user can still move them from one cell to other cell remaining empty cells. I want user to able to change the items' order. Items must be layed out from left to right without any spaces. I saw something like in a Flow Layout Example in Qt.

    When user drags an item, the special placeholder should appear between other items under mouse pointer. When user drops the item, the list widget should insert it between other items.



  • Oh, I see. I don't think that functionality is built into QListWidget. I guess you could subclass QListView and reimplement the drag event to move the widgets around so that there was always a "hole" under the cursor.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.