[Interest] Re-ordering items in QListWidget by drag-and-drop

Tony Rietwyk tony at rightsoft.com.au
Mon Oct 1 16:55:56 CEST 2012


> Sent: Tuesday, 2 October 2012 12:12 AM
> 
> On 10/1/12 9:55 AM, R. Reucher wrote:
> > On Monday 01 October 2012 15:54:30 R. Reucher wrote:
> >>> What else should I set so I can reorder items? Or does QListWidget
> >>> not support it?
> >>
> >> You have set the dragDropMode property to InterMove!
> > Correction: the property's value is 'InternalMove'.
> 
> That doesn't work. This how I setup the widget:
> 
>      m_inkList->setSelectionMode(QAbstractItemView::SingleSelection);
>      m_inkList->setMovement(QListView::Free);
>      m_inkList->setDragEnabled(true);
>      m_inkList->viewport()->setAcceptDrops(true);
>      m_inkList->setDropIndicatorShown(true);
>      m_inkList->setDragDropMode(QAbstractItemView::InternalMove);
> 
> I forgot to mention this is Qt 5. On Mac there's no visual hint on
anything
> being selected or movable. On Windows, I can see selection of one item but
> still not movable.

I think you also need to use QListWidgetItem::flags Qt::ItemIsDragEnabled.
I'm not sure about the Qt::ItemIsDropEnabled flag for internal moves.  

Tony.





More information about the Interest mailing list