Good practice?
-
If I want to create a class called Receiver which should listen on a port and work with the incoming messages, should I derive it from Q***Socket or should I give the class an attribute ?
-
It is not mandatory to derive from socket class IMO
It all depends up on you. You may have an object of your TCP class in side your own separate listener class or you can listen in the TCP class itself and then do the processing in some other thread
-
I would go for the composition pattern (socket as attribute in the class). You seem to not want to change the socket's behaviour or add some functionality to it (what would be an indicator for using inheritance). It's the same as with a QTextEdit - if you just use it, you will not inherit it, but use it as an attribute :-)