Qt Edit And Build


  • Be able to create and manage a Qt project via *.pro files
  • Know key facts about the Qt build process and the tools used (qmake, moc, Makefiles)
  • Learn how to use Qt with Qt Creator and supported IDEs

qmake Project Files

  • *.pro files
  • contain all the information required by qmake to build your application
  • Different types of elements:
    • Variables
    • Comments
    • Built-in Functions
  • qmake generates a Makefile that you then use to build the project, and you can then run your platform's make tool to build the project
  • qmake manual


  • variables are used to hold lists of strings.
  • These variables inform qmake about the configuration options to use, or supply filenames and paths to use in the build process.
  • For example, the list of values in the HEADERS and SOURCES variables are used to tell qmake about header and source files in the same directory as the project file.

Example: Header and source files are defined. CONFIG variable is used for general project configuration options.

HEADERS = mainwindow.h paintwidget.h
SOURCES = main.cpp mainwindow.cpp \
CONFIG += qt


  • Comments begin with the # character and continue to the end of the same line.

Built-in Funtions

  • qmake provides a number of built-in functions to allow the contents of variables to be processed.

MOC: Meta-Object Compiler

  • program that handles Qt's C++ extensions
  • The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes.
  • The C++ source file generated by moc must be compiled and linked with the implementation of the class.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.