How to make signal slot work faster
-
I wrote one qt application which has two threads.
Main thread/GUI thread which typically launches one QWebView window and plays some movie in youtube website. Another thread is the worker thread which is connected to some server and getting x,y,w,h rectangle info, and then I am emitting signals to main thread to reposition the QWebView window based on this coordinates.My problem is when I emit the signal to main thread, main thread takes approx 1~2 mins of delay to process that emitted signlas, because of that I am seeing slowness in the repositioning of my QWebView window.
Please advice how can I make my main therad to act on this emitted signal immediately.
Note :- I tried to reposition the QWebView window from the worker thread itself , but looks like Qt doesnt allow to access GUI elements to be accessed from worker threads.
-
-
Thanks Andre for the suggestion, but would you please elaborate more on how can I make my GUI thread to return to event loop frequently.
I am not gettiing any way to do so.Any help will be greatly appriciated.
-
To make sure you return to the event loop, you:
- Make sure you don't do bussy waiting
- Don't use the waitFor... methods in the Qt API, but use asynch methods instead
- Break up long operations in smaller bits and return to the event loop inbetween
- Offload longer operations to separate threads, and perform these asynch again
These are just some tips. It depends on your application what would give you the most milage. You'll have to do some profiling to find out, I guess.
-
But I am just playing a youtube video in a QWebView window using gui therad, thats it.
How can I split this task even further in the smaller pireces or can look for Async way. I guess this is up to the qt web view to make gui thread busy based on video being played and makes it free accordingly.I observed more slowness when I play high defination video in youtube.