Cannot create children for a parent that is in a different thread.

在線程中new對象時添加this提示:
Cannot create children for a parent that is in a different thread.
去掉this就好了

void SocketThread::run()
{
    qDebug() << "線程1:" << QThread::currentThread();
    QTcpSocket *m_socket = new QTcpSocket(this);//錯誤
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章