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.
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.
.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 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
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:
.vcprojfile containing Windows-specific settings and listing the files in the project.
.profile containing Linux and macOS specific settings.
qmakeinclude file) listing the files in the project.
© 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.