[SOLVED] Terminal Won't Stay Open in Console Project

  • Hello!

    I recently began developing in Qt, but I am having an issue with console projects. When I run my program (Console Program), terminal opens and then immediately closes so I cannot see the output.

    Here is the code that I am using:

    #include <QtCore/QCoreApplication>
    #include <QDebug>

    int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);

    qDebug() << "In the stream";
    return a.exec&#40;&#41;;


    I looked in my project's .pro file and it seems to be setup correctly (it is configured to use the console with CONFIG += console). I am not sure why the terminal window won't stay open. I have tried adding @system("PAUSE")@

    This does not work however. I am using Ubuntu and the default Qt Creator settings. Could someone tell me how to keep the console/terminal open so I can see the @qdebug@ output.


  • Lifetime Qt Champion

    Hi and welcome to DevNet,

    How do you start your program ?

  • Hello.

    To start the program I press the green play button (Run), but I have tried pressed play button with a bug on it (Debug). I also would like to note that when I press the stop button next to Application Output, nothing happens ; if that makes a difference.

    Thanks for replying.

  • Update:

    I can ./ the executable the QtCreator makes, but when I run the program with QtCreator the terminal window immediately closes.

  • Hi,

    If you disable the terminal then you can get the qDebug() output in Qt Creator "Application output pane", In order to do that Goto Projects -> Run Settings -> Uncheck Run in terminal checkbox.

  • Disabling terminal worked, thanks!

  • Lifetime Qt Champion

    Nice that the solution was found !

    Don't forget to update the thread's title so other forum users may know that a solution has been found :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.