PDA

View Full Version : GUI in more then one thread.



T4ng10r
7th May 2010, 12:14
In some situations I would like to split GUI in two threads - one (main) for general processing, second for creation of time-consuming widget. They could be created in background, when user sees only start widget. I assume that I have at least few second before he decide to change tab or call other dialog - they could be created in this second thread.
Unfortunately - first experiments shows that I cannot add widget to other in other thread. During signal/event processing (like doLayout or updates) program crash with info - cannot do that in two different threads.

is there any possibility to do this?

squidge
7th May 2010, 16:03
GUI processing should be done in the main thread only.

wysota
7th May 2010, 16:33
You can render to a QImage in a worker thread and then you can render the result to the widget in the main thread.

T4ng10r
11th May 2010, 13:35
My concerns lies in time-consuming creation process of Persistent editors. In my project I create them on third tab, so they are not visible at the start. But when user decides to show this tab - GUI freezes when they are created/shown.
So I would like to send creation of those editors in background so they wouldn't freeze GUI.

wysota
11th May 2010, 15:11
You can't. And even if you could, it wouldn't help anything. It's not creation of those widgets that makes your gui slow. You can ask faldżip, on this forum he is probably the most experienced person in this subject :rolleyes:

squidge
11th May 2010, 15:50
Why not create those editors at startup and then just show them when necessary? Then when someone clicks on the tab it will be instant.