void MainWindow::handleGetReply(QNetworkReply *reply)
{
qDebug() << reply;
}
void MainWindow::on_getDetailsButton_clicked()
{
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(
manager,
SIGNAL(finished(QNetwokReply *reply)),
this,
SLOT(handleGetReply(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl("http://google.com")));
}
由于某些原因,这不起作用,我有以下信息:
QObject::connect: No such signal QNetworkAccessManager::finished(QNetwokReply *reply) in ..\MyApplication\mainwindow.cpp:63
QObject::connect: (receiver name: 'MainWindow')
答案 0 :(得分:3)
使用SIGNAL和SLOT宏连接信号时,只需要传递信号传输的数据类型,在您的情况下应该是:
connect(manager,
SIGNAL(finished(QNetworkReply *)),
this,
SLOT(handleGetReply(QNetworkReply*)));
虽然建议使用new syntax:
connect(manager,
&QNetworkAccessManager::finished,
this,
&MainWindow::handleGetReply);