[Development] QWidget mouse events - different order

Nicolás Alvarez nicolas.alvarez at gmail.com
Thu Dec 19 03:30:16 CET 2013


2013/12/18 Andreas Aardal Hanssen <andreas at hanssen.name>:
> On 18 Dec 2013, at 22:07, Rayner Pupo Gómez <rpgomez at uci.cu> wrote:
>
>>> I've discovered that with Qt5 I get a different order of mouse events on
>>> a QWidget than with Qt4 (openSuse 13.1 Linux, X11):
>>> double clicking a widget results in Qt4 in:
>>> mousePressEvent
>>> mouseReleaseEvent
>>> mouseDoubleClickEvent
>>> mousePressEvent
>>> mouseReleaseEvent
>>> but in Qt5 in:
>>> mousePressEvent
>>> mouseReleaseEvent
>>> mousePressEvent
>>> mouseDoubleClickEvent
>>> mouseReleaseEvent
>>> I tested with Qt4.8.5 and Qt5.2.
>>> Is this behavioral change intended, undefined, a bug ?
>>> (it results in my app not behaving as before ...)
>>> --
>>
>> I think it's a mistake to rely on the order of this kind of events, there are
>> fired asynchronously, your logic cant depend on this
>
> Wrong! The order is very essential and can and must be relied on.
>
> The behaviour in Qt 5 is questionable. I believe the double-click must come first to be able to distinguish from two presses.
>
> I also wonder if it’s accurate / true that Qt 4 sends the second press after the double-click. AFAIR:
>
> Press
> Release
> DoubleClick
> Release
>
> Is the right events for double-clicking.

That would break many use cases, such as QSpinBox, which performs an
action on every press (not release) and doesn't care about double
click events.

-- 
Nicolás



More information about the Development mailing list