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. Unexplained delay after QProgressBar finish loading
Forum Updated to NodeBB v4.3 + New Features

Unexplained delay after QProgressBar finish loading

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.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.
  • G Offline
    G Offline
    GoldenAxe
    wrote on last edited by
    #1

    Hi all,

    I have emit signal from a loop (which make some calculations) that triggers progress bar update which located on the main GUI, after the loop ends the progress bar updated to 100% (the progress bar become hidden when the process ends), but than there is a delay, the progress bar stays on 100% and sometimes the mouse changes to busy, and only after few seconds the progress bar become hidden (indicates me that the delay ends), there is nothing after that loop, so nothing I can thinks of can make this delay.

    • I should note that if the loop calculations are light (meaning not a lots of calculations need to be done) there is no such delay.

    The emit signal is inside a class in the logic layer, I have try something by including <QtGui/QApplication> into that class (which sounds to me not the right thing to do, as this is the logic layer so why it should need QtGui libraries, but I'm only testing something), I put the following code qApp->processEvents(); inside the loop and now things seems to run smother, no busy mouse, but still there is a delay (the only thing different I can react with the GUI while this delay occurs, but there is no updated results until this delay ends).

    Because of the test with the processEvents() I was thinking it's something related to threads, but if so how can I correct the delay behavior, of-course if anyone thinks it could be something else, please do tell.

    Some sample code:

    Logic layer class:

    @#include <QtGui/QApplication>
    ...

    processMethod(...)
    {
     Loop(...)
     {
      qApp->processEvents();
      emit processBarSignle(value);
      ...some calculations...
     }
     emit processBarSignle(100);
    }@
    

    View layer (MainWindow):

    @ on_btn_nextProcess_clicked()
    {
    m_ui->pBar_process->setVisible(true);
    LogicClass->processMethod(...);
    m_ui->pBar_process->setVisible(false);
    }@

    Thanks

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

      You emit the signal before the calculation occurs. Loop has to go the whole cycle before it will update the progress bar with processEvents(). Maybe that is the cause.

      (Z(:^

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GoldenAxe
        wrote on last edited by
        #3

        The delay was before I used processEvents().
        But nevertheless, you mean to do something like this:

        @processMethod(...)
        {
        Loop(...)
        {
        ...some calculations...
        qApp->processEvents();
        emit processBarSignle(value);
        }
        emit processBarSignle(100);
        }@

        or this
        @processMethod(...)
        {
        Loop(...)
        {
        qApp->processEvents();
        ...some calculations...
        emit processBarSignle(value);
        }
        emit processBarSignle(100);
        }@

        ?

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

          @
          processMethod(...)
          {
          Loop(...)
          {
          ...some calculations...
          emit processBarSignle(value);
          qApp->processEvents();
          }
          emit processBarSignle(100);
          }
          @

          Not sure that will change anything in your case, but it has some potential :)

          (Z(:^

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GoldenAxe
            wrote on last edited by
            #5

            You was right it didn't worked, but was worth to try :P

            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