So I'm trying to have a while loop executing durring the main loop of my program. IE, the while loop goes in the background, and it lets me use the program like normal. I can't seem to get this right, and what I tried was putting it in the main loop, right in between MainWindow.show(). and return app.exec();. However, this just made the while loop iterate once. I tried it the same way with a for loop, and the for loop goes until it stops, and lets me use the program durring the loop, but it doesn't let me use any of the current variable values, only the values the variables had when the program started.

Here's my int main() function. The two loop statements I tried are in the block comments.
The i used in the while statement is initialised globally at the beginning of the program, right after the include statements.

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication app(argc, argv);
  4. MainWindow window;
  5. window.show();
  6. /*for (int i=0; i < i + 1 ; i++)
  7.   {
  8.   window.label->setNum(i);
  9.   }*/
  10.  
  11. /*while (i)
  12.   {
  13.   window.label->setNum(i);
  14.   i++;
  15.   qApp->processEvents();
  16.   }*/
  17. return app.exec();
  18. }
To copy to clipboard, switch view to plain text mode