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

Stephen Chu stephen at ju-ju.com
Mon Oct 1 19:02:37 CEST 2012


On 10/1/12 10:55 AM, Tony Rietwyk wrote:
>
>> 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.

Thanks. I had that flag set but forgot to also set ItemIsSelectable. And 
setting both allows me to drag-order the items.




More information about the Interest mailing list