PDA

View Full Version : Thread Issue: Unable to update UI



GAURAV PANT
27th May 2014, 11:37
Hi,
I am developing an Qt application.
It has one loop which keep on running for long time and at the same time i want to update the value in Ui.
Whats happening in my case is UI become unresponsive for some time.

I have created a background thread and running the loop in that thread but it seems that only this thread is running and result is not updated in UI. Only final value of loop is printed in Ui.
Eg if loop runs 7000 times then only 7000 is displayed in UI, rest of values are not displayed.

Code :


class bgthread :Qthread
{
run()
{
loopFunction()
}
}

loopfunction()
{
emit valuechanged(i);
}


class guiCreate:Qmainwindow
{
connect(bgThread,SIGNAL(valuechanged(int)),this,SL OT(updateui(int)));

}

guiCreate::updateui(int i)
{
iterationQLabel->setText(QString::number(i));
}

anda_skoa
27th May 2014, 18:46
Paste some actual code and use code tags.

Cheers,
_