Results 1 to 7 of 7

Thread: socket in thread error!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Aug 2006
    Posts
    163
    Thanks
    12
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: socket in thread error!

    Not only that, but if you want to use Qt's signals and slot mechanism, you HAVE to call exec() in the threads run() method otherwise the thread has no event loop. (Well, I suppose you could implement an event loop yourself but that yould be nasty ). So ditch the while loop and jsut call exec() in the thread's run() method. Handle all of the signal's emitted by the socket in socket.cpp (or whatever the name of your subclassed QTcpSocket is). Connect all the signals and slots in the constructor of your QTcpSocket subclass (or in the run() method of your thread, but personally I find that messy). I can't get any clearer than that

    If you want an example, see http://knewz.svn.sourceforge.net/vie...ewz/trunk/src/ Look at the classes connection.h/cpp and socket.h/cpp and see how I implemented this there.

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

    alphaboy (18th November 2007)

Similar Threads

  1. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  3. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  4. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.