Alex Rivera | Logout

Is it possible to use cin with Qt?

Asked 2010-02-23T21:28:57.167
12

Is it possible to use cin in Qt? I can use cout but cannot find examples of how to use cin within a Qt console application.

Edit
Report

1 Answer

8

Yes, it's possible and works as expected although you can do things, like use threads, that may cause problems with this approach.

However, I would recommend a more idiomatic (Qt) way to read from stdin:

QString yourText;
QFile file;
file.open(stdin, QIODevice::ReadOnly);
QTextStream qtin(&file);
qtin >> yourText;
answered 2010-02-23T21:49:20.070

Your Answer