Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Loading Large Image, busy indicator on a Single Thread
QtWS25 Last Chance

Loading Large Image, busy indicator on a Single Thread

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jh224
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      @QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
      yourLengthyCalculationHere();
      QApplication::restoreOverrideCursor();@

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jh224
        wrote on last edited by
        #3

        Thanks, That works great. The operation takes so long that on the title bar it says (not responding). Do you how to prevent this?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          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).

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved