

有人可以解释如何正确使用 readLine()函数,所以我不必循环通过 readAll 到 QByteArray 中来解析每一行?我使用终端Qt Widgets示例来创建这个异步串口读取功能。Ĭan someone please explain how to properly use the readLine() function so I don't have to loop through readAll() into the QByteArray to parse each line? I used the "terminal" Qt Widgets example to create this asynchronous serialport read functionality.

However, the QIODevice::readLine() function is extremely slow, and clearly blocking data from being received at full frequency compared to QIODevice::readAll() QByteArray allData = serial->readAll() As mentioned below, which I will reiterate, I have already tried the addition of Where readData() is defined as: void MainWindow::readData() signal/slot connection on readyRead() is as follows:Ĭonnect(serial, SIGNAL(readyRead()), this, SLOT(readData())) The line length may very, but it is very easy to extract the data from the format of each line. The data I'm reading from a serialport (in Qt, using QtSerialPort/QSerialPort) is separated by the newline '\n' and return '\r' characters, which is the way I intend to look at it for parsing.
