Importing and Exporting Projects

Qt and Visual Studio use different file formats to save projects. If you build your application on multiple platforms, you probably already use Qt .pro files with qmake. Otherwise, you might use .vcproj files and Visual Studio to build your project, which is usually more convenient for Windows-only development.

Qt VS Tools provide a way to combine both approaches so that you do not have to manually maintain .pro files and .vcproj files in parallel. You start by creating a .vcproj file, as usual. When you need a qmake .pro file for storing Linux and macOS specific settings, select Extensions > Qt VS Tools > Create Basic .pro File.

Export Projects dialog

If you have multiple Qt projects in one Visual Studio solution, the basic .pro file generator can create a master .pro file of type subdirs that includes all of the projects.

The generated .pro file is not meant to be a complete file, but a simple starting point for porting to other platforms. However, these files should be sufficient for compiling the skeleton projects created by the predefined Qt project wizards. The .pro file includes a .pri file.

The .pri file contains the list of source files, header files, .ui files, and .qrc files in the project. To generate the .pri file, select Extensions > Qt VS Tools > Export Project to .pri File. When you add or remove a file from the Visual Studio project file, you must regenerate the .pri file to ensure that the application can still be built on other platforms.

Also, make sure that the .pri file included in the .pro file points to the correct file. If you saved the .pri file using the suggested path and name, this reference should be correct.

Developers on platforms other than Windows might add or remove files to the project by editing the .pri file. When this happens, Windows developers must select Extensions > Qt VS Tools > Import .pri File to Project to synchronize the Visual Studio project file with the .pri file.

If your project contains platform-specific source files, you should list them in the .pro file so that they are not overwritten by Qt VS Tools.

To summarize, a cross-platform Qt project consists of the following files:

  • A .vcproj file containing Windows-specific settings and listing the files in the project.
  • A .pro file containing Linux and macOS specific settings.
  • A .pri file (a qmake include file) listing the files in the project.

If you already have a .pro file but no .vcproj file, select Extensions > Qt VS Tools > Open Qt Project File (.pro) to convert your .pro file to a .vcproj file. The generated .vcproj only contains Windows-specific settings. Also, there is no other way to convert a .vcproj file back to the .pro file format than using the Create Basic .pro File function.

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.