[Qt-interest] bug in drag and drop? QApplicationPrivate::mouse_buttons was in a wrong state after dnd operation
liang jian
jianliang79 at gmail.com
Mon Nov 2 06:10:36 CET 2009
QApplicationPrivate::mouse_buttons is the variable which track the
system mouse button state. it will be updated when spontaneous
QEvent::MouseButtonPress and QEvent::MouseButtonRelease event is sent
to Qt. During a dnd operation, only the QEvent::MouseButtonPress is
sent to Qt, and it will set Qt::LeftButton flag in
QApplicationPrivate::mouse_buttons,but the QEvent::MouseButtonRelease
event was never sent to Qt after the dnd operation ( it was eat by
window system), this will leave QApplicationPrivate::mouse_buttons in
a wrong state.
In general, this will not cause any problem, because the next
mouse click by user will correct the state in
QApplicationPrivate::mouse_buttons. But I have encountered an anoying
problem caused by this:
After a dnd operation I created a child tool button widget in the
widget who receive the drop, and the mouse pointer is in the rectangle
of the child tool button widget, and when Qt call setVisible() for the
child tool button widget it will call a funtion called
QApplicationPrivate::sendSyntheticEnterLeave(), this function will
simulate mouse enter/move/leave for the widget under the mouse pointer
and it will use QApplicationPrivate::mouse_buttons to construct the
QMouseEvent object, but at this time the
QApplicationPrivate::mouse_buttons is in a wrong state, it will
finnally cause the child tool button widget repaint itself as in a
pressed down state which looks obviously wrong.
More information about the Qt-interest-old
mailing list