2023-07-26 17:48:35 +08:00
|
|
|
#ifndef MAINTHREAD_H
|
|
|
|
#define MAINTHREAD_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
class MainThread : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static void post(std::function<void()> func);
|
|
|
|
~MainThread();
|
|
|
|
private:
|
|
|
|
static std::shared_ptr<MainThread> createShared(QObject* bindObject = nullptr);
|
|
|
|
private slots:
|
|
|
|
void mainThreadSlot(std::function<void()> func);
|
|
|
|
private:
|
|
|
|
MainThread(QObject* bindObject = nullptr);
|
2023-09-13 15:11:22 +08:00
|
|
|
QPointer<QObject> _bindObject;
|
|
|
|
bool _ignoreNullObject{ false };
|
2023-07-26 17:48:35 +08:00
|
|
|
};
|
|
|
|
#endif // MAINTHREAD_H
|