Results 1 to 3 of 3

Thread: Is it OK to use `waitForReadyRead()` instead of slot for `readyRead()` signal?

  1. #1
    Join Date
    Jun 2017
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Is it OK to use `waitForReadyRead()` instead of slot for `readyRead()` signal?

    Writing a cross platform app using Qt (including Windows with MinGW). For reading data from SSL socket, I am creating a separate thread. This thread is there for historical reason, because earlier the app was written using C socket/ssl/crypto libraries. Now all these are being replaced with Qt Network library.

    For blocking thread, waitForReadyRead(milliseconds) seems a better choice. Now according to Qt hierarchy:

    QIODevice
    |
    QAbstractSocket
    |
    QTcpSocket
    |
    QSslSocket

    Documentation of QAbstractSocket::waitForReadyRead() suggests:
    Note: This function may fail randomly on Windows. Consider using the event loop and the readyRead() signal if your software will run on Windows.
    But the similar warning is Not mentioned in the QIODevice::waitForReadyRead().

    Question: Is QSslSocket::waitForReadyRead() consistently usable for all the platforms?

    This query is also posted on stackoverflow: https://stackoverflow.com/q/44544684/514235

    ---

    Why am I not using `readyRead()` signal?
    For some strange reason, if I `slot` some method with `readyRead()` then it's not getting called. Moreover, the `QSslSocket::write()` also doesn't work, which works otherwise with above approach. Due to complexity of my code, I am unable to present it here.
    Last edited by iammilind; 15th June 2017 at 09:17. Reason: removing tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Is it OK to use `waitForReadyRead()` instead of slot for `readyRead()` signal?

    The 'strange reason' is likely that the thread in question is not running an event loop. Since you have the thread there anyway, it's easiest to simply call its exec() to enter the loop. Or don't use the extra thread at all, you don't need it for anything.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2017
    Posts
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Is it OK to use `waitForReadyRead()` instead of slot for `readyRead()` signal?

    Yes, you are right. However suppose if I want to use `waitForReadyRead()` entirely instead of `readyRead()` signal, would that be fine?

Similar Threads

  1. Connect ReadyRead-Signal with Slot
    By mikrocat in forum Qt Programming
    Replies: 3
    Last Post: 10th November 2015, 14:56
  2. Replies: 10
    Last Post: 3rd January 2015, 13:25
  3. Qextserial on debian linux and readyRead slot
    By zamek42 in forum Qt Programming
    Replies: 11
    Last Post: 18th December 2013, 19:32
  4. QTcpSocket waitForReadyRead() not re-emitting signal
    By alitoh in forum Qt Programming
    Replies: 3
    Last Post: 2nd November 2012, 13:29
  5. Replies: 0
    Last Post: 1st August 2011, 14:06

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.