Important: Please read the Qt Code of Conduct -

is there QProgressBar on StatusBar in the other thread Demo?

  • is there QProgressBar on StatusBar in the other thread Demo?
    i want to do sth really slow...and is it possible to add and update the QProgressBar on the StatusBar of the QWidget which i so the things? will it be frozen while doing things?
    or should i add the QProgressBar in a new QWidget in a new Thread?
    what is the normally and best way to use QProgressBar ?

  • Lifetime Qt Champion


    You can't manipulate GUI elements in another thread, however you can use signals and slots between object in another thread and widgets.

    Hope it helps

  • @SGaist it's QueueConnection....and the slot implement when it returns to the main thread .... does it fit the situation that update the progressBar when its parent widget is frozen on the main thread in some situation?

  • There are 2 usual cases of using timers with lengthy computation:

    1. computation is performed in the gui thread.

    you need to call void QCoreApplication::processEvents ( QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents ) [static]
    periodically from the function you run computation at to allow gui(progress bar for example) to update,

    1. Computation done in separate thread(s)
      In this case GUi thread is not busy and you do not have to do anything to update it,
      But you use thread safe notification: (signal/slot with specific connection type or QCoreApplication::postEvent ( QObject * receiver, QEvent * event )

    Second way usually leads to more responsive and faster applications, but usually is more difficult to implement right.

Log in to reply