Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Loading Large Image, busy indicator on a Single Thread

    General and Desktop
    2
    4
    2053
    Loading More Posts
    • 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
      jh224 last edited by

      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 Reply Quote 0
      • M
        MuldeR last edited by

        @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 Reply Quote 0
        • J
          jh224 last edited by

          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 Reply Quote 0
          • M
            MuldeR last edited by

            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 Reply Quote 0
            • First post
              Last post