PDA

View Full Version : HOW CAN I INPUT A QString IN THE CONSOLE



ayanda83
26th August 2012, 16:21
Hi everyone, How can I input a QString in the console? In short i've got a QString variable in my program which I want to input a string in. If it was an STL string I would have used the function getline() but I'm not sure which function to use with QString. please help.

spirit
26th August 2012, 16:43
You still can use getline with conjunction of std::string::c_str and pass this value to QString's ctor.


...
std::string str;
std::getline(std::cin, str);
QString qString(str.c_str());
qDebug() << qString;
...

ChrisW67
26th August 2012, 23:24
A whole line:


QTextStream s(stdin);
QString value = s.readLine();