btzs
btzs

Reputation: 1108

use of undeclared identifier 'connect'

I'm trying to write a simple downloader in qt. It's based on this example: http://www.ggkf.com/qt/qnetworkrequest-to-download-an-image

downloader.cpp:

void Downloader::GetImage( QString _url, QNetworkAccessManager *qnam ) {
    connect( qnam, SIGNAL( finished( QNetworkReply *) ), this, SLOT( replyFinished(   QNetworkReply * ) ) );

    QUrl url = QUrl( _url );
    QNetworkRequest request( url );

    qnam->get( request );
}

But I get the following error:

/Users/name/ssl/downloader.cpp:19: error: use of undeclared identifier 'connect'
connect( qnam, SIGNAL( finished( QNetworkReply *) ), this, SLOT( replyFinished( QNetworkReply * ) ) );

Can anyone of you explain to me this error?

Upvotes: 9

Views: 17547

Answers (1)

Ryeeeeee
Ryeeeeee

Reputation: 156

please ensure Downloader does inherit from QObject.

class Downloader : public QObject{

}

Upvotes: 14

Related Questions