Answer the question
In order to leave comments, you need to log in
How to implement a console command line in QT using standard streams?
Hello. I am making a server application for my little game. I could do it using the GUI and this question was not there, but I wanted to implement it using the command line. Those. a window into which we drive in console commands and get answers, but this application also works by itself with clients, of course.
The simple server is the server constructor in which we launch it. We created, connected everything using signal slots, and open a separate stream, which actually works with stdin and stdout.
gserver::gserver(int nPort) : NextBlockSize(0)
{
//создание, соединение и прочее опустил
logadd("server ready"); // моя функция добавления в журнал(сообщений
thread.start();
thread.run();
}
void ThreadIO::run()
{
qtin = new QTextStream(stdin);
qtout = new QTextStream(stdout);
QString line;
line = qtin->readLine();
// далее идет обработка и прочее.
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question