Using Visual Studio
1. Configure Environment
Define a QT_ROOT environment variable that points to the location of your Qt installation, and a QUILT_ROOT environment variable that points to the directory containing Quilt.
You will also need to install Ruby 1.8.6 or later.
2. Create Pre-Build Step
Open your project's properties, and create a pre-build step with a command line of:
"$(QUILT_ROOT)\quilt.rb" --moc --in="$(ProjectDir)\..\Source" --out="$(ProjectDir)\..\Source\QtGlue.moc"
The --in parameter controls the directory to scan for files that contain Q_OBJECT definitions, and the --out parameter indicates where to save the list of files that require moccing (this file must have a .moc extension).
A --exclude parameter can also be supplied, which defines a regexp to filter the scanned files (e.g., "--exclude=Mac*" will exclude any files starting with "Mac").
3. Add Rule
Right-click on your project, select "Custom Build Rules...", "Find Existing...", then select the Support/Visual Studio/Quilt.rules file:
4. Add Source
Create an empty text file as your QtGlue.moc file, and add it to the project.
After adding this file, drag it from the "Resources" section of the project into the "Sources" section.
If you have any .qrc or .ui files, these should also be added to the project.
Quit Visual Studio, and edit the .vcproj file with a text editor. For each file to be processed by Quilt (.moc, .qrc, or .ui files), add a corresponding .cpp file reference in the "Sources" section.
<File RelativePath="Source\QtGlue.moc" > </File> <File RelativePath="$(IntDir)\QtGlue.cpp" > </File>
For each foo.xxx file, Quilt generates a $(IntDir)\foo.cpp file. These files must be included in the project to be compiled, however since these are relative to $(IntDir) they must be added by editing the project file directly.
How It Works