PDA

View Full Version : Drag and Drop



chris_helloworld
31st March 2010, 08:42
Hi all, I wonder if anyone can help with some drag and drop issues.

I have a tree with various items in it. I want to be able to drag an item into text editors etc.. which if fairly straightforward to achieve, (by creating suitable QDrag and QMimeData objects and executing QDrag::exec()). However, I want to extend this basic functionality as follows,

a) Be able to show a representation of the object being dragged in a little preview window attached to the cursor during the drag operation. (I've done this before in Java /Swing simply by creating a window with no decorations and moving it in response to mouse move events). This doesn't seem possible in Qt, (at least on Windows), as the event queue seems blocked during drags. Is there any way around this problem ?

b) I want to be able to use keyboard modifiers to change the data being dragged. For example, if the object being dragged represents a database table, I want to be able to drag the table name, however, if the alt key is pressed the tablename is inserted as a fully qualified table name. Is there any way to achieve this ?

Thanks,
Chris.

Lykurg
31st March 2010, 08:54
a) Be able to show a representation of the object being dragged in a little preview window attached to the cursor during the drag operation. (I've done this before in Java /Swing simply by creating a window with no decorations and moving it in response to mouse move events). This doesn't seem possible in Qt, (at least on Windows), as the event queue seems blocked during drags. Is there any way around this problem ?
QDrag::setPixmap()

chris_helloworld
31st March 2010, 09:03
Thanks,
I will give this a go. It doesn't directly resolve my requirements though as it cant be changed after the drag has started, and hense doesnt support my second requirement.

Cheers,
Chris.