Using QT, how to call function once after a certain interval, even if more calls may occur?

sm11963 picture sm11963 · Jan 11, 2013 · Viewed 10.5k times · Source

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.

Answer

simotek picture simotek · Aug 22, 2014

If you only want to call a slot once off a timer you could look at something like

QTimer::singleShot(500, this, SLOT(MySlot()));

Then your guaranteed it will only happen once.

To clarify, by calling the static version of this rather then calling it from a existing timer it will only happen once.