Minimal QTCreator Project - Just main.cpp writing to cout
-
Hello,
I just installed the QTSDK for windows. I am excitied about being able to develop cross platform Qt applications.
However, I have some old c++ files that I used to gmake together with g++ on Linux. I would like to be able to complie and run some of these old "console" codes.
In preparation for that, can I compile and run the following code with QTCreator:
@
#include <iostream>int main()
{std::cout << "Hello Console";
return 0;
}
@
I have been playing around with the empty Qt project but have not figured it out yet.Is it possible to run the above code and see some console output ?
How
Thanks,
tenbusch
[edit: code highlighted / Denis Kormalev]
-
Of course it is possible.
Add to your .pro file
@
QT -= core gui
CONFIG += console
@P.S. And don't forget to use @ tag for code
-
You can create console project -> Other Project >> Qt Console Application, and then add your code. So in the ed you get code like this
@
#include <QtCore/QCoreApplication>
#include <iostream>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);std::cout << "Hello Console"; return a.exec();
}
@
Update: Sorry for dubling the answer -
Thanks for the replies. I did figure out the second method or fix. But I am much more interested in the first since it doesnt involve any modification of the code, just the .pro file.
Denis could you please give the contents of the .pro file if the source is in main.cpp - I did not understand the @ tag for code.
Thanks,
tenbusch
-
this should work I think
@
QT -= core gui
CONFIG += console
TARGET = helloworld
TEMPLATE= app
SOURCES = main.cpp
@About @ tag. When you post code here use @ character before and after your code to highlight it