Skip to content

Joris Vergeer

Just some software engineer with some skills

Menu
  • Home
Menu

[C++/QT] QFuture delay method

Posted on March 1, 2023March 1, 2023 by joris

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.

Work

Currently working for and owner of RetailEntertainment B.V.
  • MKB-Muziek
  • Zorgscherm
  • Zorgstand
  • [C++/QT/OpenSSL/JWT] Minimalistic implementation to create a signed JTW token.
  • [C++/QT] QFuture delay method
  • [Vite] Copy vite build output to destination directory
  • [Python][Clang] Extract variabele value from a c++ file in python
  • [ASP.net Core] Body based routing with custom MatcherPolicy
  • March 2023 (2)
  • February 2023 (1)
  • January 2023 (1)
  • July 2020 (1)
  • November 2019 (1)
  • May 2019 (1)
  • March 2019 (2)
  • DevOps
  • Programming
  • Uncategorized
  • Web

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2023 Joris Vergeer | Powered by Minimalist Blog WordPress Theme