[Qt-interest] How to detect drag drop on a QListWidget (Signal?)

Andreas Pakulat apaku at gmx.de
Fri Aug 6 14:14:12 CEST 2010


On 06.08.10 12:45:55, Matthias Pospiech wrote:
> I could find out that drag and drop can be enabled using this code:
> ui->listWidget_MacroCommands->setDragEnabled(true);
> ui->listWidget_MacroCommands->setDragDropMode(QAbstractItemView::InternalMove);
> 
> However I can not find any signal which indicates that such a move has 
> happened.
> All I want to know is which index moved to which different index.

There's no way to get that, except by either subclassing or installing an
event filter to listen to the drag/drop events. Then you'd have to find out
the indices from the events x/y coordinates.

Also I doubt the indices are being moved, I'd rather expected the data to
be moved (and new indices to be created for the data that is being moved)
 
> Can somebody give me a hint where to learn how to use drag and drop the way
> I want to use it - I only want to be able to rearrange elements in a 
> QListWidget.

Then why are you interested in which change occurs? The listwidget allows
dragging around elements already after the above setters are called.

Andreas

-- 
You never hesitate to tackle the most difficult problems.



More information about the Qt-interest-old mailing list