How to import CMake project in Qt Creator

Importing a CMake project into Qt Creator is easier than it is with Eclipse (which is described here). The problem is that you cannot do this properly by using the Import option. Counter-intuitively, you need to Open Project to import a CMake project and make a Qt Creator project from it. After this operation, the project will be available in Qt Creator always, with auto-complete (thanks to indexing) and building (thanks to make).

To do this:

  • Do Open file or project and open the CMakeLists.txt file.
  • Choose the Build directory properly. Qt Creator will create a .cbp file here with the name of the CMake project.
  • Qt Creator will ask you to run cmake once, so that it can learn the include, library and build directories.
  • You are now in the project Qt Creator has created for you. It will index the files perfectly, so you get excellent auto-complete (better than Eclipse).
  • Click the Projects button in left column and you will be able to set the command options to build and the environment variables for build.

Tried with: Qt Creator 3.5.0 and Ubuntu 14.04

How to add include directory to Qt project

The method to add an include directory to a Qt project depends on how the project was created.

If the project has a .pro file, then add this line to it:

INCLUDEPATH += "C:\some\include\path"

If you have Qt Creator open with the project, you can find the .pro file under the project name. Alternatively, you can use any editor to edit this file. Remember to run qmake after adding the include directory.

If the project has a .includes file, then just add the path directly to it:


Tried with: Qt 5.2.0 and Windows 7 x64

How to get started with Qt on Windows

Qt is a popular application framework to develop cross-platform GUI applications. Installing and using it on Windows is quite easy:

  1. From the Qt downloads page, download a Windows installer. The online installer is the best choice, since it allows you to install Qt built for all types of platforms. However, I found that the online installer was very slow and would stop downloading after a while. So, I decided to go with an offline installer. For Windows offline installers, you need to decide among these parameters: compiler (MinGW or Visual C++), compiler version (Visual Studio 2010 or 2012), architecture (32-bit or 64-bit) and OpenGL support. Depending on the combination you pick, say Visual Studio 2012 32-bit with OpenGL, you can find a corresponding installer for offline installation. Download and run the installer and it will install Qt source, libraries and tools under C:\Qt directory. The actual executables will be placed in a deeper directory. For example, mine were in C:\Qt\Qt5.2.0\5.2.0\msvc2012

  2. From the Start menu, open Qt Creator. This is the IDE that needs to be used to write a Qt application.

  3. In Qt Creator, create a new project by choosing File > New File or Project. Choose Applications and Qt Widgets Application if you want to create a GUI program. In the following dialogs, you will be asked to provide a name for the project, directory to store the files and a kit to use for compilation.

  4. This creates a project file with extension .pro and three source files: main.cpp, mainwindow.cpp and mainwindow.h.

  5. To compile this project, right-click on the project name in Projects section and choose Run qmake. This runs qmake which creates Makefiles relevant to your environment. Right-click on project name again and choose Build. This uses the Makefiles that was created earlier to build an executable. Finally right-click and choose Run. This runs the executable, which should result in an empty window being displayed. From here on, you can add source code to these files or more source files to extend this window into a Qt application.

Tried with: Qt 5.2.0, Visual Studio 2012 and Windows 7 x64