Loading Large Image, busy indicator on a Single Thread
-
I'm loading a large Image in a graphics view. I try to show the user a busy indicator, but since it is happening in the MainWindow and since it is on single thread, the busy indicator never shows. Is there a way to show the busy indicator in this situation?
-
Don't block the "main" thread with lengthy calculations ;-)
Do all stuff that takes a lot of time in a background thread and use Signals&Slots for communication. Note that GUI access needs to be done in "main" thread, but you can still load and maybe resize the image in the background before you actually show it.
If your lengthy calculation did consist of multiple separate calls, e.g. like a loop with many iterations, you could also call qApp()->processEvents() at regular intervals, but that always has the danger of unwanted side effects (as it also processes user input and, for example, slots might be called as a result from user input action - which probably is NOT what you want in the middle of a lengthy calculation).