qt event event handling

qt event handling

Qt event processing is disgusting, each event is independent. If multiple events occur at the same time, some events cannot be received in Qt.
You can refer to the event processing part of the qtbase source code. All events are processed in switch...case, so only one event will be processed in a loop.
Insert image description here
In the main window, you can set the mouse click and sliding event operations through setMouseTracking (by default, the mousemove event occurs only when the mouse remains in the Down state). If there is no sub-control in the qwidget, the mouse remains in the Down state and cannot receive messages.

Reference code, QEvent::MouseMove and QEvent::MouseButtonPress, it is impossible for the same loop to process two events at the same time. Tasteless! ! !


In terms of code, avoid processing two events at the same time through a single event.

Guess you like

Origin blog.csdn.net/daoer_sofu/article/details/131345070