Results 1 to 3 of 3

Thread: QBuffer::readLine()

  1. #1
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QBuffer::readLine()

    Qt Code:
    1. #include <QtCore>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QCoreApplication app(argc, argv);
    6. QBuffer buf;
    7. buf.open(QIODevice::ReadWrite);
    8. buf.write("Hello!\n");
    9. qDebug() << buf.data(); // prints Hello!\n
    10. qDebug() << buf.canReadLine(); // returns false!
    11. qDebug() << buf.readLine(); // returns an empty string!
    12. }
    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?

  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: QBuffer::readLine()

    This is correct. You didn't rewind the buffer. If you seek to the beginning of the buffer, you will be able to read from it.
    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
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QBuffer::readLine()

    Oops! Dzękuje.

Similar Threads

  1. how can convert QFile to QBuffer?
    By learning_qt in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2009, 13:34
  2. QBuffer bytesWritten() problem
    By QAlex in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2009, 09:05
  3. Why is QBuffer's close call so slow?
    By eekisa in forum Qt Programming
    Replies: 4
    Last Post: 8th April 2009, 12:07
  4. Streaming QImage (QByteArray, QDataStream, QBuffer)
    By knarz in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2009, 22:05
  5. External Lib read from QBuffer on Calback problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2008, 19:43

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.