Handling network timeout in Qt
When dealing with QNetworkReply , it is prescribed to use timers to abort the connection. Here is my current code: void ImageDownloader::download(QString imgUrl){ this->timeoutTimer = new QTimer(this); this->timeoutTimer->setSingleShot(true); this->timeoutTimer->setInterval(15000); connect(this->timeoutTimer, SIGNAL(timeout()), this, SLOT(timeout())); QUrl requestUrl(imgUrl); QNetworkRequest nwRequest(requestUrl); this->imageNwReply = this->nam->get(nwRequest); connect(imageNwReply,SIGNAL(finished()),this,SLOT(imgDownloaded())); connect(imageNwReply, SIGNAL(downloadProgress(qint64,qint64)),