#ifndef ASYNCEXEC_H #define ASYNCEXEC_H #include "qcoreapplication.h" #include #include #include #define async_exec(a) \ QThreadPool::globalInstance()->start(new LambdaRunnable(a)); class LambdaRunnable : public QRunnable { public: LambdaRunnable(std::function action) { this->action = action; } void run() { this->action(); } private: std::function action; }; #endif // ASYNCEXEC_H