Important: Please read the Qt Code of Conduct -

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

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

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

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

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

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

Log in to reply