Using Qt, I\'m attempting to read the contents of the stdin stream in a non-blocking fashion. I\'m using the QSocketNotifier to alert me when the socket has recieved some ne
I've found and example in other answer that fits almost to this question and with complete and simple code:
https://stackoverflow.com/a/7389622/721929
I've used it to implement a QT console based app with a textual menu to choose on user selection.
Line buffering.
Default is flushing after a "\n". If you write 5 lines to your process, your slot gets called 5 times. If you want to avoid that, you have to call setbuf(stdin, _IOFBF). But even then it is not guaranteed you can read arbitrarily large amounts of data in one chunk.
Edit: It would probably better to use QTextStream::atEnd() instead of select, since QTextStream has its own internal buffers.