#include <QtCore>
int main(int argc, char *argv[])
{
buf.write("Hello!\n");
qDebug() << buf.data(); // prints Hello!\n
qDebug() << buf.canReadLine(); // returns false!
qDebug() << buf.readLine(); // returns an empty string!
}
#include <QtCore>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QBuffer buf;
buf.open(QIODevice::ReadWrite);
buf.write("Hello!\n");
qDebug() << buf.data(); // prints Hello!\n
qDebug() << buf.canReadLine(); // returns false!
qDebug() << buf.readLine(); // returns an empty string!
}
To copy to clipboard, switch view to plain text mode
I'm using QBuffer for a unit test and I've found this behaviour. I'm using 4.6.2. The Qt docs state you can use readLine() but in fact it returns an empty string. Is this correct or a Qt bug?
Bookmarks