Qt World Summit: Register Today!

ProgressBar Blocking Window [solved]

  • Hi, guys.

    When I use QProgressBar to show progress of one operation, it will block the whole window.
    Is there any way to avoid this? I must put the operation to another thread? Is there any function to do this in QProgressBar?


  • Lifetime Qt Champion


    What do you mean by "it will block the whole window" ? While doing your long operation, do you update the progress bar ?

  • Hi,
    I mean the window is frozen. I cannot manipulate other widgets until the peration is done.
    How to update the window?

  • Lifetime Qt Champion

    It depends on the operation. Is it an external call you make ? Do you have full control on the operation ? etc…

  • Hello ausn_63,
    Yes you can do with threading...
    Just make another thread class with signal that provides updates to progressbar and emit it(signal) within the thread , The corresponding slot should be in main thread.
    I am sure your Application will not be frozen..

  • Thanks.

    I just think the default QProgressBar maybe has this function.
    Because I saw all of the progress bars from other software will not be frozen while it's running other operation, like copying progress bar when I'm copying some files from one folder to another.
    It seems that I must use another thread to do it.

  • Lifetime Qt Champion

    QProgressBar can't have this function. How could it know you are doing anything ? You have to provide it with this information. Also you must not block the GUI thread with your long lasting operation. To handle this you have two options: move that lengthy operation in another thread or periodically call processEvents(). Both have their pros & cons. It's up to you to decide what's the best for your application.

  • I got it!
    Thank you!!

  • Lifetime Qt Champion

    You're welcome !

    If you have it working now, can you please update the thread title prepending [solved] ? So other forum users may know a solution has been found :)

  • Ok, bro.

Log in to reply