- 【Win/Mac/Linux/Android/iOS】 Qt 総合スレ 19
124 :デフォルトの名無しさん[sage]:2020/09/28(月) 22:01:36.75 ID:iMi4NbKw - class myClass : public QObject{
Q_OBJECT private: QThread* th; public: myClass(); virtual ~myClass(){} pulic slots: void fin(); signals: void thread_quit(); }; myClass():th(new QThead()){ connect( this, &myClass::thread_quit, th, [&]{ th->quit(); th->wait(); delete th; } ); moveToThread(th); // other initializations th->start(); } void myClass::fin(){ moveToThread(th->thread()); emit thread_quit(); }
|