How to make QT SDK work with VisualStudio (Express/Complete)

You can use the following steps to make QT SDK work with your Visual Studio (either express version or commercial version).

  • Download the QT SDK from https://qt.nokia.com/downloads/sdk-windows-cpp
  • If you do not have VisualStudio get Express version for free from https://www.microsoft.com/express/download/
  • Once QT and VisualStudio both are installed and ready, open the VisualStudio Command Prompt (from Microsoft Visual Studio | Visual Studio Tools menu of Program Files)
  • Change directory to the QT SDK installation folder in the Command Prompt. Usually it would be of the form "C:\Qt\2010.05\qt"
  • Execute the configure.exe by typing configure in the command prompt. This should start configuring the QT for VisualStudio and Windows. Let it complete.
  • Once the configuration is complete, build QT for use with Visualstudio by issuing the command nmake
  • Configuration and the following nmake will take some time. Once they are complete, your QT SDK will be ready for use with VisualStudio.
  • To let VisualStudio recognize the include and library files of QT, add their paths to the VisulStudio Tools|Options|Projects and Solutions|VC++ Directories section. Typically you would want to add C:\Qt\2010.05\qt\include to the Include, C:\Qt\2010.05\qt\lib to the libraries and C:\Qt\2010.05\qt\bin to the Executables sections.
  • Also you can add C:\Qt\2010.05\qt\bin to the Path System variable so that the QT dlls get probed correctly when loaded from your application. (You can use MyComputer|Properties|Advanced|Environment Variables)

Now your QT SDK is ready to be used with Visual Studio. Go to Examples directory of your QT SDK installation (typically, C:\Qt\2010.05\qt\examples) and open the examples.sln file from your Visual Studio. (If double-clicking the .sln file does not open automatically with Visual Studio, open it manually from within Visual Studio.

Build and run the tutorial1 project. If your Include, Library and Path System variable settings are correct, you should have the project output build and run successfully.

Usually you should be able to generate the visual studio project files from the Qt .pro file with the qmake application using the -tp vc command line options. For example, qmake -tp vc myproject.pro

You can associate the .ui files to the QTDesigner by right clicking any .ui file in the solution explorer and selecting "Open With" option. In the Open With options dialog, click 'Add' button and select the designer.exe from the QTSDK bin directory (typically, it would be C:\Qt\2010.05\qt\bin\designer.exe). Click 'Set as Default' to let the QTDesigner handle the .ui files.