• 4881阅读
  • 1回复

请教关于线程的问题。 [复制链接]

上一主题 下一主题
离线bluegem218
 

只看楼主 倒序阅读 楼主  发表于: 2014-05-17


void FortuneServer::incomingConnection(qintptr socketDescriptor)
{
    QString fortune = fortunes.at(qrand() % fortunes.size());
    FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    thread->start();
}

如上代码中,线程指针thread,在new FortuneThread之后,是不是不需要用delete thread来删除?它运行完后,会自动删除掉或者回收?
离线realfan

只看该作者 1楼 发表于: 2014-05-17
创建时,传入parent,当parent对象被删除时,以这个parent为父对象的子对象会被自动删除。
快速回复
限100 字节
 
上一个 下一个