Managing Projects
|
Property | Description |
---|---|
Version | The Qt version to use for this project (see Basic Qt Version Management). |
MonitorPriFile | The .pri file to monitor, if you want to be notified when other developers modify the .pri file (see Importing and Exporting Projects). |
MocDirectory | The directory (relative to the project) where the generated moc files are put. This directory must include the $(ConfigurationName) variable, to ensure that the moc files for different configurations (e.g., debug or release) do not collide. |
MocOptions | Additional command line options for the moc build step. |
UicDirectory | The directory (relative to the project) where the uic generated header files are put. |
RccDirectory | The directory (relative to the project) where the rcc generated source files are put. |
When a Qt project is created, these properties are initialized to default values based on the current information found in the Qt pages of the Tools|Options dialog. The dialog also allows you to set global, project-independent settings:
Global Setting | Description |
---|---|
AutoRunUic | If true, uic is run each time the form editor loses focus (when you switch to another tab). This is useful to regenerate the database for code completion. |
AutoUpdateMocSteps | If true, moc steps are updated whenever the preprocessor defines, include paths or the MocDirectory of the project are changed. (In VS 2003, the moc steps will always be updated when the source/header file is changed.) |
AutoUpdateUicSteps | If true, uic steps are updated whenever the UicDirectory of the project is changed. |
AutoUpdateRccSteps | If true, rcc steps are updated whenever the contents of a qrc file or the RccDirectory of the project is changed. |
Note: Setting the AutoUpdate values to false have no effect when adding new files or removing existing files. In these cases, the corresponding steps are always added or removed.
The Visual Studio integration offers its own simple Qt version management, enabling you to use multiple versions of Qt 4 in parallel, e.g., Qt 4.0.1 and 4.0.2. When you install the integration, the information about Qt versions is added to the user registry hive. So, another user will have to add a new Qt version since no default version will be set.
To add or remove Qt versions, click Tools|Options and select the Qt|Builds page. Click Add, then enter a name for the Qt version and the path to Qt's root directory, for example, C:\\Trolltech\\Qt-4.0.1". The first added Qt version is automatically the default version which will be used when creating new projects or importing a project from a .pro file. The default versions for Qt Windows or Windows CE projects can be changed using the combo boxes located under the Qt Builds list.
To specify which Qt version a project should use, select the project node of a Qt project (e.g., "Project1") in the Solution Explorer, and set its Version property using the property browser.
Changing the Qt version for all projects in the solution can be done by invoking the context menu of the solution and activating the Change Qt versions... item. You can then select your desired Qt version in the dialog listing all available Qt versions.
Note: When you set a Qt version for the solution, this version becomes the default version if you add new projects to the solution.
Using the Qt Visual Studio Integration does not require a globally set Qt environment variable. The integration will always overwrite the existing global Qt environment variable.
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, usually convenient for Windows-only development.
Qt's Visual Studio integration provides a way to combine both approaches - 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 want a qmake .pro file, select Qt|Create Basic .pro File to generate a .pro file where you can store Unix and/or Mac OS X specific settings.
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. Having said, 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 Qt|Export Project to .pri File. Whenever you add or remove a file from the Visual Studio project file, you must regenerate the .pri file to ensure that the application will still build on other platforms.
Also, ensure that the included .pri file in the .pro file points to the right file. If you saved the .pri file in the suggested path and name, this should be correct.
Non-Windows developers can add or remove files to the project by editing the .pri file. When this happens, Windows developers must select Qt|Import .pri File to Project to bring the Visual Studio project file in sync with the .pri file. You will be notified regarding these changes if you set the MonitorPriFile property of the project to the path of the .pri file.
If your project contains platform-specific source files, these files should be listed in the .pro file so that they are not overwritten by the Visual Studio integration.
In summary, a cross-platform Qt project consists of the following files:
If you already have a .pro file but not a .vcproj file, select Qt|Open Solution from .pro File to convert your .pro file to a .vcproj file. Be aware that the generated .vcproj only contains Windows-specific settings. Also, there is no way to convert a .vcproj file back to a .pro file format, apart from the basic .pro mechanism described above.
[Previous: Getting Started] [Contents] [Next: Adding Form Files to the Project]
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt vs-integration-1.4 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com