Qt 多线程简单应用

日常打盹 / 2023-08-22 / 原文

声明:
QThread* thread;

初始化:

thread = new QThread();
    thread->start();
将对象放到线程中去:
moveToThread(thread);
readTimer.moveToThread(thread);
    readTimer.setSingleShot(true);

连接消亡信号:
connect(thread, SIGNAL(finished()), this, SLOT(thread_done()));


注销:

thread->quit();
    thread->wait();
    thread->deleteLater();