通常、プロセス集中型の関数を使用している場合は、呼び出しQCoreApplication::processEvents()たりQEventLoop::processEvents()、処理が他のシグナルやスロットをブロックしないようにすることができます。
ただし、新しい を作成してワーカーをそのスレッドに移動すると、 を呼び出すまたはQThreadがありません。QCoreApplicationQEventLoopprocessEvents()
QEventLoop私の調査によると、作成した新しいにをインストールできるはずでQThreadあり、それを呼び出すことができprocessEvents()ますQEventLoop。
ただし、これを行う方法がわかりません。次のようになると思います。
QThread *thread = new QThread(this);
Worker *worker = new Worker(this);
QEventLoop *loop = new QEventLoop();
connect(thread, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
connect(thread, SIGNAL(started()), worker, SLOT(startProcessing()));
connect(worker, SIGNAL(done()), thread, SLOT(quit()));
connect(worker, SIGNAL(done()), loop, SLOT(quit()));
worker->moveToThread(thread);    
//loop->exec() // blocks processing of this thread
loop->moveToThread(thread);
//loop->exec() // loop is not a member of this thread anymore and even
               // if it was, this would block the thread from starting
thread->start();
//loop->exec(); // loop is not a member of this thread anymore and even
                // if it was, this would block this thread from continuing
ループを開始しようとするすべての場所には、何らかの問題があります。しかし、このようなものが機能したとしても、どうすればそれを呼び出すprocessEvents()ことができQEventLoop()ますか?
または、QThread関数もあり、関数もありますが、setEventDispatcher()サブクラスのものを見つけることができないようです。QAbstractEventDispatcherprocessEvents()QAbstractEventDispatcher
で集中的なワーカー機能中にイベントを処理する適切な方法は何QThreadですか?