Originally Posted by
jacek
Create an object, connect it to readyRead() signal of the device on which QTextStream operates and let it read the input.
I am new to QT and I am sure that I am missing something. Nevertheless, I tried to implement your advise and in doing so I stumbled upon another problem. I created ConsoleInput class:
class ConsoleInput : public QObject
{
Q_OBJECT
QTextStream ts;
public:
ConsoleInput(QObject *parent) : ts(stdin), QObject(parent)
{
connect (ts.device(), SIGNAL (readyRead()), this, SLOT(lineIsReady()));
};
~ConsoleInput() {};
private slots:
void lineIsReady()
{
QString line = ts.readLine();
};
};
my main.cpp is:
int main(int argc, char *argv[])
{ QCoreApplication a(argc, argv);
ConsoleInput cn(&a);
return a.exec();
};
Now I cannot get an input from the console. What am I doing wrong?
Bookmarks