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(); }