这是代码:
QEventLoop eventLoop;
QNetworkAccessManager mgr();
QObject::connect(mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QUrl url(site);
QNetworkRequest req(url);
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();
if (reply->error() == QNetworkReply::NoError) {
cout << "Success" endl;
delete reply;
}
else {
cout << "Failure" endl;
delete reply;
}
发现错误:
.. \ request.cpp (17): error C2665: 'QObject :: connect': 3 个重载都不能转换各种主题
和
..\request.cpp (20): error C2228: '.get' 左边的元素必须是类、结构或联合