Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
lunatic last edited by
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 ?
Immii last edited by
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
goetz last edited by
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 :-)