[Interest] How QApplication takes input from Windows Console?

Berkay Elbir berkayelbir at gmail.com
Thu Sep 3 13:41:45 CEST 2015


Hello All,

I have a problem about command prompt. I have a C++/Qt GUI desktop
application on windows 7. But I also need to run this application from
command prompt for example:

myApp.exe -l myfile -ic.

I can launch and use my app functionality from command prompt successfully
but if I need to take an input from user on command prompt, I can not take
inputs. When I enter an input, output is

  Accept values? y(yes)n(no)
  y
 'y' is not recognized as an internal or external command,
  operable program or batch file.

I am taking user input like this:

char userResponse = 'n';
std::cin >> userResponse;if (userResponse == 'y' || userResponse ==
'Y' ){
    ...             }

emit myWorkDone();return false;

The problem is that program waits on waiting user input line. When
myWorkDone signal is emitted, application quits for normal conditions.

In main:

 QApplication a(argc,argv);...> QObject::connect(&argProcessor,
SIGNAL(finishedProcessor()) ,&a,    >
SLOT(quit()),Qt::QueuedConnection);>     >       return a.exec(); //
Main application

After that I discovered that QApplication does not listen Windows Console,
it listens the console of the application.

Is there a way taking input from Windows console in QApplication?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150903/0e52405e/attachment.html>


More information about the Interest mailing list