gpt4 book ai didi

c++ - 如何同步QNetworkAccessManager?

转载 作者:行者123 更新时间:2023-11-28 07:27:23 25 4
gpt4 key购买 nike

我的 deleteIdList 变量来自 replyFinished(QNetworkReply*) 函数。但是 deleteIdList 变量返回空。但是,它必须返回任何东西..我想同步 QNetworkAccessManager..

    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*)));

foreach (QString delIdList, deleteIdList) {

serviceUrl = "http://localhost:8080/limit_id="+delIdList+"&false";
requestUrl = QString("%1%2:%3%4").arg(scheme).arg(qstr).arg(QString::number(svcPort)).arg(serviceUrl);

QUrl url(requestUrl);
QNetworkRequest request;
request.setUrl(url);
manager->get(request);

}

如何同步QNetworkAccessManager?

最佳答案

我可能会迟到,但我认为这可以帮助其他人面对这个问题。

QNetworkAccessManager *networkMgr = new QNetworkAccessManager(this);
QNetworkReply *reply = networkMgr->get( QNetworkRequest( QUrl( "http://www.google.com" ) ) );

QEventLoop loop;
QObject::connect(reply, SIGNAL(readyRead()), &loop, SLOT(quit()));

// Execute the event loop here, now we will wait here until readyRead() signal is emitted
// which in turn will trigger event loop quit.
loop.exec();

// Lets print the HTTP GET response.
qDebug( reply->readAll());

Source : developer.nokia.com

关于c++ - 如何同步QNetworkAccessManager?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18511623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com