Results 1 to 4 of 4

Thread: how to operate tcpsocket in thread again

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: how to operate tcpsocket in thread again

    i) use [code] tags
    ii) with Qt signals & slots and you do not really need to put that code into a separate thread
    iii) if using QThread: put your code into a separate class (not the QThread subclass!) and create that in your thread's run() function. You should not add slots/signals to the QThread subclass itself. There are some postings that elaborate on that. Search for them, please.
    (The QThread belongs to the thread that created it, not to the thread it is executing itself.)

    HTH

  2. #2

    Default Re: how to operate tcpsocket in thread again

    Quote Originally Posted by caduel View Post
    i) use [code] tags
    ii) with Qt signals & slots and you do not really need to put that code into a separate thread
    iii) if using QThread: put your code into a separate class (not the QThread subclass!) and create that in your thread's run() function. You should not add slots/signals to the QThread subclass itself. There are some postings that elaborate on that. Search for them, please.
    (The QThread belongs to the thread that created it, not to the thread it is executing itself.)

    HTH
    thanks for your help,but i think i don't explain my desigh explicility

    firstly,I want to create a thread,and creat a socket in the thread for some client's connection.
    secondly,I want the gui-mainthread to notify the created thread to send some message to the client..So I use signal/slot for it,just like i clicked a button,then emit a signal which send by gui to the created thread,it is a blocked operation.
    now the slot recfserveris useful for accept the signal,then i want to operate tcpsocket in the slot.can i into the run for the operation?
    could you tell me what other methods which can realize the function
    thank you very much!

  3. #3

    Default Re: how to operate tcpsocket in thread again

    Quote Originally Posted by succulent_lily View Post
    thanks for your help,but i think i don't explain my desigh explicility

    firstly,I want to create a thread,and creat a socket in the thread for some client's connection.
    secondly,I want the gui-mainthread to notify the created thread to send some message to the client..So I use signal/slot for it,just like i clicked a button,then emit a signal which send by gui to the created thread,it is a blocked operation.
    now the slot recfserveris useful for accept the signal,then i want to operate tcpsocket in the slot.can i into the run for the operation?
    could you tell me what other methods which can realize the function
    thank you very much!
    i subclass Qtcpsocket,and transfer the signal to the thread ,then to the socket,the problem is solved ,thanks for your help

Similar Threads

  1. QT + OpenGL + Thread => aaaahhhhh !
    By anthibug in forum Qt Programming
    Replies: 7
    Last Post: 26th July 2008, 13:36
  2. Replies: 5
    Last Post: 17th January 2008, 21:49
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  5. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44

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.