c++ - Why is not Qt label refreshed? -
this method call button click
void changelabeltext(qlabel* mylabel) { int countnumber = 0; for(int = 0; < 9999; i++)//outer loop { for(int k = 0; k < 65000; k++)//inner loop { countnumber++; } mylabel->settext(qstring::number(countnumber)); } }
when code runs text of label set @ end of outer loop
, expected set label's text every time inner loop
finishes. might causing it?
your code executed in main thread , in main thread th ui update happens on events callbacks. need force repaint ui. can calling repaint()
or asking aplication process events qcoreapplication::processevents()
. need make after changing label.
Comments
Post a Comment