使用Qt发布数据时出错

时间:2012-11-04 20:17:08

标签: qt post

我想使用此代码将数据发布到PHP表单,但在编译之后我有消息:

  

Object :: connect:没有这样的信号NetworkReplyImpl :: finished(QNetworkReply *):

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
    QUrl params;
    QUrl url("localhost/test2.php");
    params.addQueryItem("name","aaa");
    params.addQueryItem("country","bbb");

    QByteArray data;
    data.append(params.toString());
    data.remove(0,1);

    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QNetworkReply *reply = manager->post(QNetworkRequest(url), data);
    connect(reply, SIGNAL(finished(QNetworkReply*)), this,SLOT(replyFinished(QNetworkReply*)));

}


MainWindow::~MainWindow()
{

}
void MainWindow::replyFinished(QNetworkReply *reply)
{
    QString data = reply->readAll().trimmed();
    qDebug() << data;
}

1 个答案:

答案 0 :(得分:2)

该消息非常清楚:QNetworkReply没有信号finished(QNetworkReply*)。但它确实有一个信号finished(),它不带任何参数。你不能这样回复。