UI Multithreading
-
Folks;
I have an application with many dialogs that perform screen updates at a very high rate. All of the screen updates appear to be done from the main UI thread. When I run on linux, top reveals that this thread is consuming nearly all cpu time. On a multi-core machine I would like to spread this load out across other cores. Does Qt5 have a mechanism for doing this. -
@rickm said in UI Multithreading:
Does Qt5 have a mechanism for doing this.
No, all GUI specific stuff has to be done in the main thread. But I wonder what you're updating all the time (and if this is really needed at all since noone will be able to follow the updates)
-
Hi,
Can you be more precise about what that high volume streaming data is ?
-
Hi
also how you are read it, if its done in main thread also, that could also account
for the high usage. -
@rickm said in UI Multithreading:
data read from a sensor.
And where/how the sensor reading and eventually some data processing is done?
Are you using threads for such tasks? -
Hi
also how you are read it, if its done in main thread also, that could also account
for the high usage.@mrjj The data is read from a socket that is serviced by a non-ui thread. the data is collated and stored in appropriate structures. When enough data is gathered I call dialog->update() which triggers the dialog paint event. In the paint I load a QImage with data and use that to update the dialogs image.
-
@mrjj The data is read from a socket that is serviced by a non-ui thread. the data is collated and stored in appropriate structures. When enough data is gathered I call dialog->update() which triggers the dialog paint event. In the paint I load a QImage with data and use that to update the dialogs image.
@rickm said in UI Multithreading:
the data is collated and stored in appropriate structures
in that same or another non-ui thread?
I load a QImage with data
and the image is created in another non-ui thread?
-
@mrjj The data is read from a socket that is serviced by a non-ui thread. the data is collated and stored in appropriate structures. When enough data is gathered I call dialog->update() which triggers the dialog paint event. In the paint I load a QImage with data and use that to update the dialogs image.
@rickm Basically, you can process your audio, and prepare your QImages in other threads, but actually updating the UI has to be done in the main thread. The GUI itself is not thread safe.