- Generally speaking accessing class members directly is wrong. Instead you should provide wrapper functions/slots/whatever to handle that
- Sounds like your QTcpSocket object is an object and not a pointer. This is also considered as bad design because it is NOT a type which can be copied (noticed the Q_DISABLE_COPY() macro ?) just like basic types (int, QString, QPixmap QList<>, ... for instance) which implies that in most cases, and especially when using such objects outside of their creation scope, they should be created through new and accessed via pointers...
- There seems to be quite a misunderstanding about semantics... I used to to think that "heap allocation" referred to objects created as objects (i.e. without "new" operator) which were automatically deleted when the program leaved the creation scope whereas "dynamic allocation" referred to process of creating objects via "new" and deleting them manually with "delete". I might have been misleaded as far as names are concerned (and I shall investigate this) but my remarks still stand in your case : use pointers when dealing with network objects!
Hope this helps.![]()
Bookmarks