I want to create the simple console app below in Qt Creator:
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Hello WOrld";
return 0;
}
I’ve seen some possible duplicates on SO, I have ticked the “Run in Terminal” option in Run Settings. A console window does pop up on CTRL+R, but it does not display “Hello World”, simply “Press Enter to exit”.
The above is by creating an Empty Project.
I have tried creating a “Qt Console Application” which generates the code below. This does work fine, but I want the simple non Qt version above.
#include <QtCore/QCoreApplication>
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::cout << "Hello World";
return a.exec();
}
After trying Qt again after a long time, it now works. The project file has “CONFIG -=qt” by default. I’m not sure if this alone would have solved the problem back then, but it is the only difference I can see.
Full .pro file: