本帖最后由 隐藏英雄 于 2023-1-4 21:38 编辑
各种办法都试了,不会了。。。 不知道要传的PostData 怎么写[C++] 纯文本查看 复制代码
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
QNetworkRequest res;
QString PostData = QString("mac=00-00-00-00-00&ip=192.168.1.1"); //.arg(strMacAddress).arg(Version); //要传的是2个变量先用字符串测试,
QByteArray PostData1 = PostData.toUtf8();
qDebug() << "PostData1" <<PostData;
res.setHeader(QNetworkRequest::UserAgentHeader,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36");
res.setUrl(QUrl("http://www.xxx.com/mydata.php"));
res.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkReply* reply = manager->post(res, PostData1);
qDebug() << "PostData2" <<PostData;
|