Events disabled during moving or resizing
-
Hi,
while you're moving or resizing a QMainWindow it seems all the events are disabled. This is an odd behavior for some application, say when you're plotting "real-time" data on a graph.What is the recommended way to allow the events handling also while moving/resizing?
I'm using Qt 5.3 under Windows 7.
Thanks -
Hi,
which events seem to be disabled?
How do you send events? via postEvent with custom events? -
I'm talking about signals and slots, I'm sorry if I used the word "events" improperly.
For example I have the readyRead() slot from a QSerialPort which is not called when I'm moving the QMainWindow.
-
Ok, now wer are getting it. In which thread is the QSerialPort done?
Signals/Slots across threads are in fact event messages. These are serialized via the message queue. Maybe, moving the windows does not return to the message queue untill the window is in its final position, which means, no event processing in between. This implies no cross thread signals/slot to the main thread. -
Well, it's in the same thread of the QMainWindow.
If I understand correctly even if I move the QSerialPort in another thread I still can't process the incoming messages in the QMainWindow. This is odd, because I must update the graph con this form and I cannot do this in a separate thread, can I?Is there any workaround?
-
No, all UI activities must be done in the main thread. And if the user drags the window which might block the main thread, you can't do UI updates in between. You will also not get any QSerialPort stuff done in that time, unless it is done in a separate thread.
You could check the Qt code what happens in moving a window, whether it is done by Qt itself or by the OS code.
-
That's odd!
Anyway, the signals emitted and not received are lost or just queued?
I'm going to move the QSerialPort in another thread and, from there, emit signals to update the UI.When the user stops moving the window, will I receive the signals emitted in the meanwhile? so I can update the plot without loss of data.
-
depends on the hardware, right? Events are typically queued in the message queue. But I am sure, QSerialPort will fetch the serial data froim the hardware, once it gets called from the main thread.
If you move the serial port to a worker thread, the signals will be kept and executed later.