tags:

views:

83

answers:

1

Hi,

I'm trying to implement some kind of drag and drop feature between two widgets with Qt 4.5. So I've reimplemented the mouse events methods to do what my program is supposed to do when I press the mouse button on the first widget and move the cursor & release the button on the second one.

Problem is: after the pressEvent on the first widget no other widget receives a mouse related event (move, release or enter) before the first widget got the release event. Even the first widget doesn't receive the leave event when the cursor goes outside, if the button was not released beforehand.

How can I make the target widget receive the mouse events before the button is released?

Thanks.

+1  A: 

IIRC you don't use "normal" mouse events for drag and drop in Qt. Read the appropriate section in Qt documentation.

chalup
Yes, but with the `QDrag` class I'm forced to use the dragged data as `QMimeData` not a custom class.
gregseth
Just define a custom mime type (e.g. "application/x-mywidget"), store your data in a QByteArray and use 'QMimeType::setData()'.
Wolfgang Plaschg
Ok, but how do I get my class back from the `QByteArray` ?
gregseth