Connect to function



  • Hi
    you see code:

    In class MainWindow:

    void replyFinished(QNetworkReply *reply);
    

    In void MainWindow::on_pushButton_clicked() :

    connect(manager , SIGNAL(finished(QNetworkReply*)) , this , SLOT(replyFinished(QNetworkReply*)));
    

    In .cpp file :

    void MainWindow::replyFinished(QNetworkReply *reply)
    

    and don't work and i get message in Application Output:
    QObject::connect: No such slot MainWindow::replyFinished(QNetworkReply*) in ..\DownloadManager\mainwindow.cpp:21
    QObject::connect: (receiver name: 'MainWindow')

    Why ?
    Thanks


  • Moderators

    @Armin said in Connect to function:

    QObject::connect: No such slot MainWindow::replyFinished(QNetworkReply*) in ..\DownloadManager\mainwindow.cpp:21

    make sure you define it as slot in your .h file.

    protected slots:
           void replyFinished(QNetworkReply *reply);
    

    Alternatively you can use the new Qt5 syntax using function pointers (then it's not necessary to declare it as slot):

    connect(manager , &QNetworkAccessManager::finished, this, &MainWindow::replyFinished);
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.