Results 1 to 14 of 14

Thread: How do I use QTcpSocket properly ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How do I use QTcpSocket properly ?

    1. Generally speaking accessing class members directly is wrong. Instead you should provide wrapper functions/slots/whatever to handle that
    2. 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...
    3. 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.
    Current Qt projects : QCodeEdit, RotiDeCode

  2. The following user says thank you to fullmetalcoder for this useful post:

    mnemonic_fx (29th March 2007)

Similar Threads

  1. Tell QTcpSocket which interface to use
    By rianquinn in forum Qt Programming
    Replies: 7
    Last Post: 23rd December 2010, 17:28
  2. problem with QTcpSocket
    By SuperSonik in forum Qt Programming
    Replies: 8
    Last Post: 31st January 2007, 16:00
  3. Problems with QThread and QTcpSocket
    By cookiem in forum Qt Programming
    Replies: 6
    Last Post: 2nd November 2006, 08:25
  4. Problem with QTcpSocket and QDataStream
    By Valheru in forum Qt Programming
    Replies: 4
    Last Post: 16th September 2006, 13:08
  5. QTcpSocket disconnection problem
    By erdi in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2006, 21:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.