Results 1 to 11 of 11

Thread: QSocketNotifier: socket notifiers cannot be disabled from another thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Aug 2006
    Location
    Switzerland
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanked 13 Times in 11 Posts

    Default Re: QSocketNotifier: socket notifiers cannot be disabled from another thread

    Quote Originally Posted by dabiabilus View Post
    I have a code like this
    If it is a code, why don't you use [code] tag?

    Quote Originally Posted by dabiabilus View Post
    Qt Code:
    1. void Client::run()
    2. {
    3. tcpSocket = new QTcpSocket();
    To copy to clipboard, switch view to plain text mode 
    I assume that Client class is derived from QThread class.Parent object (Client) was probably created in the main thread. Everything that is done in its run() method is executed in another thread. So child object (QTcpSocket) is created in different thread than its parent lives. This is not allowed and that's why you get error:
    Quote Originally Posted by dabiabilus View Post
    QObject: Cannot create children for a parent that is in a different thread.
    Quote Originally Posted by dabiabilus View Post
    QSocketNotifier: socket notifiers cannot be disabled from another thread
    Hm... I'll be guessing here. Your client thread doesn't have an event loop (you're not calling exec() method anywhere in run()). You are waiting for readyRead in client thread, so in fact you are waiting for some signal from QTcpSocket. But it's impossible to receive it in client thread cause it has no event loop.
    The Wheel weaves as the Wheel wills.

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

    milli (20th May 2011)

Similar Threads

  1. question about socket and threads?
    By oob2 in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2007, 11:42
  2. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  3. 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.