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:
void button_clicked()
{
If ( button->text == “Start†)
{
button->setText(“Stopâ€);
timer->start(5000);
printf(“Hello World\nâ€);
}
else
{
timer->stop();
button->setText(“Startâ€);
}
}
void button_clicked()
{
QTimer *timer = new QTimer();
If ( button->text == “Start†)
{
button->setText(“Stopâ€);
timer->start(5000);
printf(“Hello World\nâ€);
}
else
{
timer->stop();
button->setText(“Startâ€);
}
}
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,
Bookmarks