[Qt-interest] How to detect drag drop on a QListWidget (Signal?)
Matthias Pospiech
matthias.pospiech at gmx.de
Fri Aug 6 14:42:09 CEST 2010
Andreas Pakulat schrieb:
> 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.
>
You mean that I have to evaluate pixels from the screen ???
I mean the widget isself has moved for example index 6 to inbetween 2
and 3, so 6 becomes 3.
If the widget knows about that I want to get to know that too. If I had
to realize that by calculating
the heights of all elements and trying to recalculate the new index I
would not even consider to
work with drag and drop any further... (I never used it before)
> 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.
>
>
maybe I described it too simple. I only want to move the items in the
widget _and_ rearrange the data in the
container filling the widget in the same way. Otherwise the whole widget
is refilled with the data structure
in the container class an all the reordering is lost.
Matthias
More information about the Qt-interest-old
mailing list