[Solved] QProgressBar not getting updated.
-
Hi All,
I am facing one issue related to the QProgressBar.
My QProgressBar is in the main GUI thread. One QLabel is also present.From one outside thread, i am emitting one signal which calls a slot of the Main program (GUI Main Thread) that in turns update both the QLabel and QProgressBar.
The problem is that QLabel is updated everytime but there is no effect on QProgressBar.
I have also used update() on progress bar but still it is not getting updated.Kindly let me know what can be done to resolve this.
Thanks
Siddharth
-
Dear Andreyc,
Thanks for the reply.
Here is the code:
threadObject is an object of a Class derived from QThread.
We emit the signal from this class only.In MainWindow Constructor we have written the connect statement:
@connect(&threadObject,SIGNAL(updateIndex(QString)),this,SLOT(updateUI(QString)));@
Here is the slot:
@
void MainWindow::updateUI(QString str)
{ui->label_cl72->setText(str); ui->label_cl74->setText(str); ui->progressBar->setValue(str.toInt()); // qApp->processEvents(); // QCoreApplication::processEvents();
}
@
Label is getting updated but Progress bar is not getting updated.
Thanks
Siddharth
-
Hi,
What can str contain ? Thus are you sure that str.toInt() returns a valid value ?
-
I would check with a few qDebug if you get a good value here :
@ ui->progressBar->setValue(str.toInt());@
Also make sure your progressBar has a minimum and maximum value that is valid relative to your "str" variable :
minimum < str.toInt() < maximum
if you set a value outside of the range, you won't see the QProgressBar changeGood luck
-
Dear SGaist, Maximus,
Thanks for the reply.
Yes there was some problem with the argument:
@
ui->progressBar->setValue(str.toInt());
@In the begining the str was double and then it was converted to the float and then to the string and again to the int. So everytime the value was getting 0.
The connected hardware was sending the wrong values.
Marking the thread as solved.
Thanks