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

Have a go hero – Using QSignalMapper

As discussed earlier, using sender() is a convenient, but not an object-oriented, approach. Thus, try to use QSignalMapper instead to determine which socket called the slot. To achieve this, you have to connect the socket's readyRead() signal to a mapper and the slot directly. All the signal-mapper-related code will go into the newConnection() slot.

The same applies to the connection to the removeConnection() slot. Let's take a look at it next.

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