There are two views you can take toward how Qt projects are structured: the file view and the workflow view. Depending on how your brain works and/or the issue you are trying to understand, one of these will work better than the other. In all probability, both will be useful at some point.
A Qt project is a collection of project description files, source code files, resource files, and binary output files. Some of these files must be explicitly generated using a text editor or similar tool, others are automatically generated by the build process.1)
{directory-name}.pro
qmake -project
Makefile
, Makefile.debug
, and Makefile.release
make
(Linux and OS X) or nmake
(Windows) to do the actual project build.qmake
main.cpp
main
function.{yourclass}.h
and {yourclass}.cpp
Q_OBJECT
, a Qt macro used to implement signals and slots.{yourdialog}.ui
moc_{yourclass}.cpp
YourClass
after the Q_OBJECT
macro has been fully expanded and other QObject foo is resolved.ui_{yourdialog}.
{yourdialog}.ui
.{resources}.qrc
rcc
(the Qt resources compiler) if mentioned in {directory-name}.pro.qrc_{resources}.cpp
{resources}.qrc
as static C++ arrays of compressed binary data.{directory-name}
.{directory-name}.pro
has been configured for both release and debug, then object files will be {directory-name}/release
or {directory-name}/debug
depending on how you invoked make
(or nmake
). Otherwise, object files will also be in {directory-name}
.The typical Qt project workflow consists of the following major phases: creating a project, adding files to a project, building and testing a project. These are discussed below.2)
qmake -project
in a terminal shell in the project directory. This will generate a {directory-name}.pro
project description file.
qmake -project
, they will be included in the generated {directory-name}.pro
. Having a main.cpp before you run qmake -project
will make the resulting *.pro file much easier to work with.qmake -project
only once during the life of a project. After the *.pro file's initial generation, you will need to edit it manually to add/remove files from the project (see the next section).{directory-name}.pro
to reflect the added files.qmake
to generate a new Makefile, debug
and release
sub-directories (if needed), and and other support files.
Notes:
qmake
before running building and testing.{directory-name}.pro
file to build both release and debug versions, build the project by executing make
in the project directory. If you did specify release and/or debug builds in {directory-name}.pro
, then run
make release
or
make debug
depending on what you want.
./{directory-name}
in the project directory (or use your file manager to launch the executable, or load the executable into a debugger or …).
Notes:
make clean