Как описано здесь: , вы можете подключить сигнал к простой функции, например:
connect(
sender, &Sender::valueChanged,
someFunction
);
Вот моя программа:
#include <QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
void handleReply(QNetworkReply *reply)
{
QString replyStr = reply->readAll();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QNetworkAccessManager manager;
connect(&manager, &QNetworkAccessManager::finished(QNetworkReply*), handleReply(QNetworkReply*));
return a.exec();
}
Однако я получаю несколько ошибок:
main.cpp:18: error: call to non-static member function without an object argument
connect(&manager, &QNetworkAccessManager::finished(QNetworkReply*), handleReply(QNetworkReply*));
~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.cpp:18: error: 'QNetworkReply' does not refer to a value
connect(&manager, &QNetworkAccessManager::finished(QNetworkReply*), handleReply(QNetworkReply*));
^
main.cpp:18: error: expected expression
connect(&manager, &QNetworkAccessManager::finished(QNetworkReply*), handleReply(QNetworkReply*));
^
main.cpp:18: error: 'QNetworkReply' does not refer to a value
connect(&manager, &QNetworkAccessManager::finished(QNetworkReply*), handleReply(QNetworkReply*));
^
/usr/include/x86_64-linux-gnu/qt5/QtNetwork/qnetworkreply.h:62: declared here
class Q_NETWORK_EXPORT QNetworkReply: public QIODevice
main.cpp:18: error: expected expression
connect(&manager, &QNetworkAccessManager::finished(QNetworkReply*), handleReply(QNetworkReply*));
^
^
Буду признателен за любую помощь. Спасибо.