Configuration of Qt project

An application written in cross-platform Qt. (Except for tricky third-party libraries, but that's the exception). However, to run the application on different platforms, you often still need to properly configure the Qt project. (The project is configured in the .pro file).

Configuring the Qt project when using only Qt components is done by modifying the QT variable. For example, to include opengl,

QT += opengl

the QtNetwork module

QT += network

the QtWebKit module

QT += webkit

and so on.

What needs to be added can always be found in the official manual.

When using only Qt components, you probably won't need to reconfigure the project when using it on different platforms (Windows/Linux) (if Qt is installed correctly).

But how about third-party libraries, such as qwt? In that case, you just need to specify the library's location and its includes. For example, for Linux (linking qwt6):

INCLUDEPATH += /usr/include/qwt6/
LIBS += -lqwt6

The first line is straightforward - just specify the address where the headers (.h files) are located. The second line is a bit more interesting: in this case, the address is considered to be the default location of the libraries on the system (in my case, it's /usr/lib/). The name of the library is determined as follows: if it was libqwt6, it becomes -lqwt6, meaning we replace "lib" with "-l".

On Windows, you simply need to specify the address, for example:

INCLUDEPATH += C:/libqwt6/include
LIBS += C:/libqwt/lib/libqwt6.a

Of course, besides including libraries, there are many other things you can do in the .pro file. For example, specify compilation flags.

For example, enabling support for openmp parallelization:

QMAKE_LFLAGS += -fopenmp
QMAKE_CXXFLAGS += -fopenmp

You can also include additional files in the project (this can be done with Qt Creator, which also automatically adds all the files you create in it)

If you have debugging problems, for example in a C project in Qt Creator, check if you have

CONFIG += debug_and_release