Hi guys,

I was wondering if someone could help me out with creating a button that when clicked, will print “Hello World” every 5seconds until the button is pressed again.

So far I have:
Qt Code:
  1. void button_clicked()
  2. {
  3. QTimer *timer = new QTimer();
  4.  
  5. If ( button->text == “Start” )
  6. {
  7. button->setText(“Stop”);
  8. timer->start(5000);
  9. printf(“Hello World\n”);
  10. }
  11. else
  12. {
  13. timer->stop();
  14. button->setText(“Start”);
  15. }
  16. }
To copy to clipboard, switch view to plain text mode 

Obviously, as you can probably tell, I am new to Qt and threading. Right now, it just prints out the Hello World once. How do I make it keep going every 5 seconds?
Do I have to make it an event or something?

Any help code and explanation wise would be greatly appreciated.

Thanks,