April 2018
Beginner
714 pages
18h 21m
English
A more elegant way that does not rely on sender() would be to use QSignalMapper to receive the reply object in the argument of the slot. First, you need to add the QSignalMapper *m_imageFinishedMapper private field to your class. When you call QNetworkAccessManager::get() to request each image, set up the mapper as follows:
for(const QString& url: urls) {
QNetworkRequest request(url);
QNetworkReply *reply = m_network_manager->get(request);
connect(reply, SIGNAL(finished()),
m_imageFinishedMapper, SLOT(map()));
m_imageFinishedMapper->setMapping(reply, reply);
}
In a prominent place, most likely the constructor of the class, connect the mapper's map() signal to a custom slot. ...
Read now
Unlock full access