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>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "In the stream";
return a.exec();
}
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.
When I run the project I use the default run button, but I have also tried the debug button. The terminal window still just flashes open and then closes before I can see the output. The Application Output pane at the button just says that it is starting the application. This is what my terminal settings look like in QtCreator: x-terminal-emulator -e
(this is default)
My QtCreator version is 2.4.1
Could someone tell me how to keep the console/terminal open so I can see the qdebug()
output?
Thanks