Actually it depends what you mean. Timers as such do not generate events but are rather checked as part of the event loop whether they reached their timeout. If so, then the application will generate a timer event for the object interested in the timer's timeout (be it the timer object itself or the QObject instance calling startTimer() or using QBasicTimer).
So to sum things up, this will execute the slot only once:
connect(&t, SIGNAL(timeout()), ..., ...);
t.start(1000); // 1s
sleep(100); // 100s
qApp->processEvents();// lets the timeout be checked and generates an event for the 't' object that will eventually call the slot from line #2
QTimer t;
connect(&t, SIGNAL(timeout()), ..., ...);
t.start(1000); // 1s
sleep(100); // 100s
qApp->processEvents();// lets the timeout be checked and generates an event for the 't' object that will eventually call the slot from line #2
To copy to clipboard, switch view to plain text mode
Bookmarks