Results 1 to 20 of 26

Thread: QTcpSocket: no readyRead() signal even in Qthread event loop

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QTcpSocket: no readyRead() signal even in Qthread event loop

    It took some time because Wireshark cannot catch on localhost and I had to setup another PC to test it. But Now I see that response is sent back, so socket should have this data.
    @nix: Unfortunately this project is on VS2003 and I don't see qDebug() output and errors like you. I'll try to create socket diret in run(). In this case such error shouldn't occur.


    Added after 10 minutes:


    Quote Originally Posted by nix View Post
    Are you sure you realy need another event loop? If you are, maybe you should use QThread in a other way, take a look to http://labs.qt.nokia.com/2010/06/17/...oing-it-wrong/.
    If it would work without QThread event loop, I would be happy, but it doesn't. Threrfore I've tried it with QThread. May be it's also wrong.
    I already read this article, but I don't move thread to itself. I move socket to this new thread and this shold be correct. But I'll try it without QThread subclassing. May be it differs...


    Added after 6 minutes:


    Qt Code:
    1. ClientSocket::ClientSocket()
    2. :m_isRunning(false)
    3. ,m_socket(new QTcpSocket())
    4. {
    5. QThread* t=new QThread();
    6. connect(m_socket, SIGNAL(readyRead()), this, SLOT(test()));
    7. m_socket->moveToThread(t);
    8. t->start();
    To copy to clipboard, switch view to plain text mode 
    This way slot also doesn't get called. And without subclassing QThread I cannot start QThread's event loop because exec() is protected.
    Last edited by R-Type; 20th October 2011 at 16:31.

Similar Threads

  1. Replies: 1
    Last Post: 22nd July 2010, 09:16
  2. Terminate a QThread with an event loop
    By paolom in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2010, 11:53
  3. QThread event loop blocking the GUI
    By JoeMerchant in forum Qt Programming
    Replies: 4
    Last Post: 18th July 2009, 07:54
  4. QThread event loop seems blocked
    By eurodatar in forum Qt Programming
    Replies: 3
    Last Post: 6th May 2009, 16:50
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

Tags for this Thread

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.