#ifndef MAINTHREAD_H #define MAINTHREAD_H #include #include #include class MainThread : public QObject { Q_OBJECT public: static void post(std::function func); ~MainThread(); private: static std::shared_ptr createShared(QObject* bindObject = nullptr); private slots: void mainThreadSlot(std::function func); private: MainThread(QObject* bindObject = nullptr); QPointer _bindObject; bool _ignoreNullObject{ false }; }; #endif // MAINTHREAD_H