#ifndef FUNCTIONTHREAD_H #define FUNCTIONTHREAD_H #include /*! * \brief The LambdaThread class * * Provides a QThread which performs a supplied lambda before kicking off its event loop. * * Disclaimer: this might be a crutch that reveals a misunderstanding of the Qt * threading infrastructure. We'll see. */ class FunctionThread: public QThread { public: FunctionThread() : QThread() {} void setFunction(const std::function &function) { this->function = function; } void run() override { function(); exec(); } private: std::function function; }; #endif // FUNCTIONTHREAD_H