New QT Connection Question

I just tried setting up a small QT example, and the connect statement was not compiled. error message from the compiler: "there is no corresponding function to call" MainWindow :: connect (... ""

What am I doing to her?

Thank you for your help.

#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QNetworkAccessManager> #include <QNetworkReply> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); protected: void changeEvent(QEvent *e); private: Ui::MainWindow *ui; QNetworkAccessManager networkManager; private slots: void on_requestButton_clicked(); void on_authenticationRequired(QNetworkReply* reply, QAuthenticator* auth); void on_finished(QNetworkReply* reply); }; #endif // MAINWINDOW_H 

 #include "mainwindow.h" #include "ui_mainwindow.h" void MainWindow::on_requestButton_clicked() { } void MainWindow::on_authenticationRequired(QNetworkReply* reply, QAuthenticator* auth) { } void MainWindow::on_finished(QNetworkReply* reply) { } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), networkManager(this) { ui->setupUi(this); connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(on_finished(QNetworkReply*))); connect(networkManager,SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), this, SLOT(on_authenticationRequired(QNetworkReply*,QAuthenticator*))); } MainWindow::~MainWindow() { delete ui; } void MainWindow::changeEvent(QEvent *e) { QMainWindow::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } } 
+6
c ++ qt
source share
1 answer

QObject :: connect expects pointers to QObject, you pass networkManager as a regular variable. A simple connection (networkManager ...) to connect (& networkManager ...) should do the trick.

+8
source share

All Articles