3

我想使用此代码将数据发布到 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;
}
4

1 回答 1

2

消息说得很清楚:QNetworkReply没有信号finished(QNetworkReply*)。然而,它确实有一个finished()不带参数的信号。你不能以这种方式通过回复。

于 2012-11-04T21:23:09.613 回答