Qt发送简单的http post请求

仅仅做代码备份

    QNetworkRequest request;
	QString url = "";
    request.setUrl(QUrl(url));
    request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/x-www-form-urlencoded"));
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    auto body = QString("").toLatin1();
    QNetworkReply *reply = manager->post(request, body);
    connect(manager, &QNetworkAccessManager::finished, [=](QNetworkReply* r){
        Q_UNUSED(r)
        // 处理返回结果的逻辑
    });
    connect(reply, &QNetworkReply::readyRead, [=](){
        qDebug () << "readyRead";
    });

你可能感兴趣的:(#,Qt)