Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSerialPort: call waitForReadyRead() in a slot connected to readyRead
Forum Updated to NodeBB v4.3 + New Features

QSerialPort: call waitForReadyRead() in a slot connected to readyRead

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qdoussot
    wrote on last edited by
    #1

    Hello,
    I do not fully understand if this is legitimate but I use consecutively write, waitForBytesWritten and particularly waitForReadyRead in a slot connected to the signal readyRead().

    The QIODevice::waitForReadyRead() description seems to indicate this is legitimate since
    "readyRead() is not emitted recursively; if you reenter the event loop or call waitForReadyRead() inside a slot connected to the readyRead() signal, the signal will not be reemitted (although waitForReadyRead() may still return true)."

    But the description of QSerialPort::waitForReadyRead seems to contradict the previous description:
    "The function returns true if the readyRead() signal is emitted and there is new data available for reading; otherwise it returns false (if an error occurred or the operation timed out)."

    In my case, this does not work, ie waitForReadyRead returns a timeout error, when the signal and the slot are connected in DirectConnection, but works if they are explicitly connected in QueueConnection.

    Thanks

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2
      1. This "contradict" description also is and for the QAbstractSocket. In principle, nobody understands as it there has to be, since everywhere a behavior is different.

      2. Just do not use waitForXX() inside of slot to avoid of some problems.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved