R-Type
6th July 2012, 12:24
Hello,
I've simple console application and cannot find solution how to wait for some key before exit from it. It's simple with getchar() or std::cin.ignore, but I want to do it with Qt, because for console communication I already use it:
int main() {
QTextStream cout(stdout);
QTextStream cin(stdin);
// ...
cout << "Press <ENTER> to exit." << endl;
forever {
QString Line = cin.readLine();
if (!Line.isNull()) {
break;
}
}
return 0;
}
Code inside forever was taken from stackoverflow, but doesn't work for me. Qt 4.7.3
Do you know some other solutions?
I've simple console application and cannot find solution how to wait for some key before exit from it. It's simple with getchar() or std::cin.ignore, but I want to do it with Qt, because for console communication I already use it:
int main() {
QTextStream cout(stdout);
QTextStream cin(stdin);
// ...
cout << "Press <ENTER> to exit." << endl;
forever {
QString Line = cin.readLine();
if (!Line.isNull()) {
break;
}
}
return 0;
}
Code inside forever was taken from stackoverflow, but doesn't work for me. Qt 4.7.3
Do you know some other solutions?