English Русский French [qt-devnet.developpez.com]
Table of Content
Qt Visual Studio Add-in
Getting the source
The source code of the add-in is hosted on gitorious at http://qt.gitorious.org/qt-labs/vstools
To create a repository clone, execute the following command:
- git clone git://gitorious.org/qt-labs/vstools.git
Build Instructions
Make sure that you have the following software installed:
- Visual Studio 2005 or above
- Perl
- Qt 4.7.0 or newer
Open a command shell with a Qt build environment (Visual Studio build, 32 bit) and cd into your add-in source directory.
Execute the following commands:
- cd Qt4VS2003
- createUserFiles.cmd
This sets up reference paths and debug settings.
- cd ComWrappers\qmakewrapper
- qmake
- nmake
- cd ..\..\tools\qtappwrapper
- devenv qtappwrapper2008.sln /useenv /Build release
Adjust the number in qtappwrapper2008.sln according to the VS version you’re using.
Duplicates of the addin’s project files exist for every supported Visual Studio version.
- cd ..\qrceditor
- qmake
- nmake
This builds the external QRC editor which is launched from within Visual Studio.
Now we’re ready to open the main solution which contains the actual add-in.
- start Qt4VS2003\Qt4VSAddin2008.sln
Now you should be able to build the solution.
Before trying to run your freshly built add-in, read the next section.
Running and Debugging
To run and debug the development version of the Qt Visual Studio Add-in we need to do a little
setup work once again. Note that you can have the Add-in’s release version installed.
You can switch between these two installations as you will see soon.
Install the Add-in’s Description File
Open the directory where your personal Visual Studio settings are stored. This is usually
something like “USERPROFILE\Documents\Visual Studio 2008”.
We’ll just use that directory for illustration. Also, we’ll assume that the
add-in’s repository is located in c:\dev\qtvstools.
Execute the following commands:
- cd "%USERPROFILE%\Documents\Visual Studio 2008"
- md Addins
- cd Addins
- copy c:\dev\qtvstools\Qt4VS2003\Qt4VSAddin\Qt4VSAddin.AddIn
Qt4VSAddin.AddIn is the add-in’s description file and Visual Studio can now find it.
For other Visual Studio versions than 2008 you must adjust the Version tag in the
Qt4VSAddin.Addin file.
Your installed release version of the add-in is now turned off and cannot be loaded into
Visual Studio anymore. To restore the old state, rename the file extension of Qt4VSAddin.AddIn
to some bogus value like Qt4VSAddin.AddIn.foo. This ensures that it will be ignored by Visual
Studio and the original add-in will be loaded.
Run the Add-in’s Development Version
Now that the .Addin file is in place, we’re ready to try out the development version of the
add-in. Open the solution file (e.g. Qt4VSAddin2008.sln) and press F5.
Another instance of Visual Studio is started. We will call this instance VS2 and the Visual
Studio Instance where the add-in’s solution is loaded VS1.
The add-in is not yet loaded in VS2. To load it, select “Tools/Add-in Manager…” click the
first checkbox in the “Qt4 Add-in Development Version” line and press OK.
Now you should have a “Qt” menu entry in the menubar of Visual Studio which means that the
add-in has been successfully loaded.
In VS1 you can set breakpoints and do all the debugging you need. In VS2 you’re controlling
the add-in.

