The documentation of this method states:
QByteArray QIODevice::readLine(qint64 maxSize = 0)
This is an overloaded function.
Reads a line from the device, but no more than maxSize characters, and returns the result as a byte array.
However, I notice that even if we pass
maxSize = 0, viz. don’t pass anything, the
readLine() sends several bytes in the line. Is this a well defined behaviour?
Besides, here is one decade old issue on the same topic: QIODevice::readLine(qint64 maxSize = 0) default argument performs poorly (should be documented). Is this still relevant?
It’s not mentioned in the Qt API documentation, but passing in a value of 0 as the
maxSize argument is treated as having a special meaning of "as many bytes as possible". Evidence of that intent can be seen at line 1466 of the qiodevice.cpp source file in Qt:
if (maxSize == 0) maxSize = MaxByteArraySize - 1;
Answered By – Jeremy Friesner
Answer Checked By – Candace Johnson (BugsFixing Volunteer)