QEventLoop等待另外一个事件的停止,非常实用 good

void MyWidget::SendRequest(QString strUser)
{
    network_manager = new QNetworkAccessManager();

    connect(network_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(ReadXML(QNetworkReply*)));
    QEventLoop loop;
    connect(network_manager, SIGNAL(finished(QNetworkReply*)), &loop, SLOT(quit()));
    // 发送请求
    network_manager->post(network_request, post_data);
    // 启动事件循环
    loop.exec(QEventLoop::ExcludeUserInputEvents);

    network_manager->deleteLater();
}

 

你可能感兴趣的:(QEventLoop等待另外一个事件的停止,非常实用 good)