tags:

views:

261

answers:

1

Hi,

I just tried to set up a small QT example and the connect statement fails to compile. the error message from the compiler is: "no matching function for call to 'MainWindow::connect(...'"

what am I doing wrong 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;
    }
}
+4  A: 

QObject::connect expects pointers to QObject's, you are passing networkManager as a normal variable. Just changing connect(networkManager...) to connect(&networkManager...) should do the trick.

Job
thank you very much.
Tobias Langner