O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What just happened?

First, we posted the request and fetched the pointer to the QNetworkReply object. Then, we connected the reply's finished signal to the mapper's slot map(). Next, we called the setMapping() method of the mapper to indicate that the sender itself should be sent as the slot's argument. The effect is very similar to the direct use of the QNetworkAccessManager::finished(QNetworkReply *reply) signal, but this way, we can use multiple slots dedicated to different purposes (with a separate mapper corresponding to each slot), all served by a single QNetworkAccessManager instance.

QSignalMapper also allows you to map with int or QString as an identifier instead of QObject *, as used in the preceding code. So, you can rewrite the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required