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

Advertisements

One thought on “How to get started with Qt on Windows

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.