PDA

View Full Version : Reading from QFile when QTextStream is open



dawwin
19th March 2011, 10:47
I use


QTextStream in(stdin, QIODevice::ReadOnly)

To read text from standard input. But I need getChar() function to block execution until user press enter so i need to open

file.open(stdin, QIODevice::ReadOnly);
Is this ok to call QFile::getChar when file is already open in QTextStream?

qlands
19th March 2011, 14:51
Why would you do that?

You can use QTextStream to write chars into the file. See operator <<

dawwin
19th March 2011, 18:43
I want to read characters, not write.
I need that because I want to block execution until user press enter. Something like this won't work

QString temp;
QTextStream in(stdin, QIODevice::ReadOnly);
in >>temp;

if user press enter without pressing any other character before. So I need QFile::getChar()