• 3363阅读
  • 0回复

新线程里也无法触发slot,qt的线程机制有点没看懂,请大家帮忙 [复制链接]

上一主题 下一主题
离线cyj1988jyc
 

只看楼主 倒序阅读 楼主  发表于: 2010-01-06
在新线程里QTime和http请求不能用sign/slots机制,请问大家该怎么实现
1.
void newThread::run()
{

    QTimer *timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(downloadReadyRead()));
        timer->start(5000);
    


}
void newThread::downloadReadyRead()
{

}

无法触发slot
2.
QUrl url("http://localhost/Default.aspx");
QNetworkRequest request(url);
    currentDownload = manager.get(request);
    connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)),
            SLOT(downloadProgress(qint64,qint64)));
          connect(currentDownload, SIGNAL(finished()),this,
            SLOT(downloadFinished()));
            connect(currentDownload, SIGNAL(readyRead()),this,
            SLOT(downloadReadyRead()));
新线程里也无法触发slot,qt的线程机制有点没看懂,请大家帮忙
快速回复
限100 字节
 
上一个 下一个