Using QT, how to call function once after a certain interval, even if more calls may occur?
问题 I am having a hard time wording this question even though I don't think its that complicated. I want to do something simalar to QTimer::singleshot() but I want it to still only call the SLOT once even if QTimer::singleshot() is called multiple times before it fires. 回答1: This should work. class MyObject { // ... QTimer* mTimer; } MyObject::MyObject() { mTimer = new QTimer(this); mTimer->setSingleShot(true); connect(mTimer, SIGNAL(timeout()), SLOT(doStuff())); } MyObject::startOrResetTimer() {