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. Creating wait screen
QtWS25 Last Chance

Creating wait screen

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 5.0k 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.
  • D Offline
    D Offline
    durgeshK
    wrote on last edited by
    #1

    Hello group,

    I was trying to create a screen(widget) which would display some wait symbol, while there is some background work is going on.
    Can i display a new widget on a different(new) thread? I don't have much idea about multithread programming. So if you guys can suggest me some resources, it will be very helpful to me :)

    Thanks & Regards,
    Durgesh K

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Of course you can push the widget into a new thread. But be mindful about it - you'll need a new class (namely, QThread subclass), and there is the thing of communicating with main thread (your app), which again involves some writing. If you want to go for it, then you might want to prevent your widget from accepting events (it won't need them anyway), which may speed things up a bit in some situations.

      IMO, better solution is to leave the widget in main thread, as it won't do much work anyway.

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mlong
        wrote on last edited by
        #3

        You can't display a widget in a separate thread. All GUI elements have to run in the main thread. Your best bet would be to move your processing to a separate thread.

        There's a nice "wiki page":http://developer.qt.nokia.com/wiki/Threads_Events_QObjects about threading available too.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          [quote author="mlong" date="1312577075"]You can't display a widget in a separate thread. All GUI elements have to run in the main thread. Your best bet would be to move your processing to a separate thread.

          There's a nice "wiki page":http://developer.qt.nokia.com/wiki/Threads_Events_QObjects about threading available too.
          [/quote]

          Ah, didn't know that, thanks, mlong!

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sigrid
            wrote on last edited by
            #5

            Also, note that you can use "QProgressDialog":http://doc.qt.nokia.com/4.7/qprogressdialog.html to provide feedback on the progress of a slow operation.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              durgeshK
              wrote on last edited by
              #6

              Thanks guys for the answers, atleast now i know what not to try.

              @sigrid, if i use QProgressDialog then i will have to use qApp->processEvents(), in order to update the QProgressDialog, and since at the background i am running third party DLL, i can't update QProgressDialog properly.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MichK
                wrote on last edited by
                #7

                You can always try to use "QProgressBar":http://doc.qt.nokia.com/latest/qprogressbar.html, set its minimum and maximum to 0 and its value to -1. And you get busy indicator without any progress only indicating that something is loading.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mlong
                  wrote on last edited by
                  #8

                  Unfortunately, a QProgressBar would suffer from the same shortcomings as a QProgressDialog if the main event loop is blocked by the work in progress. DurgeshK mentioned that his processing is running 3rd-party code, so there's no way to process events during the work being done.

                  Software Engineer
                  My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                  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