Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collect user input using qDebug

Tags:

c++

qt

qdebug

I have been wondering if it is possible to collect user input using the qDebug() statement in Qt C++.

I tried do it like in the std C++ code like:

qDebug() >> myvar;

but it didn't work.

How can I read from stdin using Qt?

like image 845
user2989328 Avatar asked Jun 24 '26 09:06

user2989328


2 Answers

qDebug is used to make output to stderr. If you want to read from stdin using Qt, you should use QTextStream:

#include <stdio.h>

QTextStream in(stdin);

QString line;
in >> line;
like image 95
msrd0 Avatar answered Jun 26 '26 22:06

msrd0


No, it isn't possible. qDebug provides only output stream for debugging informations.

like image 27
trivelt Avatar answered Jun 26 '26 23:06

trivelt