How to stop a QEventLoop in a command line program on a "Return" (/n) keypress?

214 Views Asked by At

I was reading around, and I got the impression (correct me if I am wrong) that keypress events work only for gui applications, and the only thing a commandline will detect is a carriage return (/n). I have a command line application, and am looking to implement this basic logic:

if (programHasError) {
    qDebug() << "Error: Your program has generated an error. Press return to quit";
    QEventLoop haltProgram;
    connect(foo,SIGNAL(pressReturn()), haltProgram, SLOT(quit()));
    haltProgram.exec();
    a.quit(); // quits commandline application.
}

How can I achieve this?

0

There are 0 best solutions below