Results 1 to 12 of 12

Thread: Socket + thread problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2
    Thanked 26 Times in 23 Posts

    Default Re: Socket + thread problem

    Easy, easy, tbscope...
    Why not ? I did moveToThread( this ) and it worked. Please say, what is wrong with that ?
    Thanks.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 69 Times in 67 Posts

    Default Re: Socket + thread problem

    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: Socket + thread problem

    Quote Originally Posted by borisbn View Post
    Easy, easy, tbscope...
    Ohh, sorry, I didn't want to insult you.
    Text messages are notoriously difficult to get the emotions from.

    It's documented that it is wrong to use moveToThread on the QThread, and if you think about it a little bit you know why it doesn't make sense to do so. See the posts above.

    You are correct though that the whole object needs to be moved to another thread. But only the object, not QThread.
    Therefor you need to create your own object and then use moveToThread on that object to move it to another thread.
    QThread needs to live in the main thread and act as a translator/manager/whatever... between the main thread and the object in the other thread.

Similar Threads

  1. socket & thread
    By prashant in forum Qt Programming
    Replies: 2
    Last Post: 2nd December 2009, 10:09
  2. thread with socket?
    By triperzonak in forum Qt Programming
    Replies: 6
    Last Post: 25th September 2008, 16:21
  3. Socket on a Thread
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 7th May 2008, 15:56
  4. Thread, Timer and Socket. Comuication problem
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 17th January 2008, 16:48
  5. How to write on a socket in another thread?
    By Valheru in forum Qt Programming
    Replies: 7
    Last Post: 12th October 2006, 10: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.