With credits for ChatGPT which after several promts still coulnd’t make 100% functional code. But it gave me the broad idea of the code I could use.
#include <QTimer>
QFuture<void> delay(int milliseconds)
{
QSharedPointer<QFutureInterface<void>> futureInterface(new QFutureInterface<void>());
QTimer::singleShot(milliseconds, [futureInterface]() {
futureInterface->reportFinished();
});
return futureInterface->future();
}
It’s simple, It’s elegant. And somehow it isn’t in the Qt codebase for as fas as I could find.