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