Remember Hello World in Chapter 1, Getting Started with Qt Creator? That was a console application, about as simple a one as you can write. Let's recap the code; we created a new Qt console application, and in main.cpp
, wrote the following lines of code:
#include <QCoreApplication> #include <iostream> using namespace std; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); cout << "Hello world!"; return a.exec(); }
Any valid C++ file is valid in a Qt application, including Standard Template Library (STL) code. This is especially handy if you need to write a small tool in C++ and haven't learned a lot about Qt yet—everything you know about C++ (and even C, if you prefer) is accessible to you in Qt Creator.
Although Qt is most widely known as a GUI toolkit, it's worth mentioning that the QtCore library, a part of every Qt application including Qt console applications, includes a bevy of utility and...