Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there really no way to move a QWidget into a new thread
Qt 6.12 LTS is out! See what's new in the release blog

Is there really no way to move a QWidget into a new thread

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 10.9k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I find it hard to believe that there is no way to move a QDialog( basically a progress form) into a new thread while i am downloading a large file. Up to this point however, i have found no way to work around this. The issue is the other class instance running at the same time is a network interface, which of course, if i try to thread that i lose my sockets. So Does anyone have a suggestion on how I can accomplish a progress bar that does not stop responding when large transfers of data are occurring?
    thanks

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      the thread that creates an object owns it, what is there not to believe?

      why not create 2 threads, one to perform the download and the other for the gui progress update.

      don't use the main thread for intensive work, otherwise the main ui will become unresponsive and result in a poor end-user experience.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        The only restriction about threads in Qt is that GUI objects can only live in the main thread. You can move any non-GUI objects to any other thread you want. So, make it like ryadav suggested, do the work in the background thread and send signals to the GUI to update the progress bar.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          Never forget: http://img337.imageshack.us/i/zv9h.mp4/

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Sorry, in that unconditional way it is purely nonsense.

            I agree, that one has to seriously think if threads are necessary to achieve a goal. And in many cases the answer is no. But to generally discourage usage of threads is counterproductive.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vishwajeet
              wrote on last edited by
              #6

              avoid thread as much as possible,
              however in your case you can have one thread which downloads the big chunk of data and emit signal to main thread where dialog box is update.

              Born To Code !!!

              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
              • Unsolved