UIC step not being ran in build using Visual Studio Add-in
-
I recently upgraded to Qt 5.0.0 and Visual Studio 2010 (from Qt 4.6 and VS 2008).
I installed the Qt Visual Studio Add-in, and converted my project to use it (previously i had set up build rules for MOC and UIC myself). But i am having a problem where UIC isn't being ran when i build.
It does the moc'ing, but then goes on to build the cpp files for my GUI dialogs. Those files reference the generated ui_*.h files, so the build fails because they are not build yet.Does anyone know why this is happening?
It's possible that i have not set it up correctly, but i cannot find any tutorials or documentation on how to use the VS add-in. I re-added some of my .ui files using project -> add -> new item, then choosing the Qt dialog item, but that didn't seem to help. -
welcome to devnet
More as a personal advice I am recommending to setup new projects in the new environment. I have tried in the past, but the success was mostly temporary.
You can setup a small example project with your new development environment and check the required settings. However, adapting every single settings is time-consuming and sometimes frustrating. At the days end my conclusion is that setting up new projects and importing the source of older projects is faster and more stable.
-
Yes, i was thinking of doing that. However, i wondered whether starting from scratch (at least in terms of settings/environment) would take more effort than just moving my existing project accross. I'm still not sure if it would be worth it, there must be some reason why UIC isn't running.
But i will try setting up a small example project like you suggest, so i can then at least see how it is supposed to work, if it does work at all. -
To expand on what i said in my previous post, i was previously using the "Qt Build Rules for Visual Studio":http://code.google.com/p/xr-qt-msvc/ because i only had the Express version of VS and couldn't use the add-in. Now that i do have the add-in, i removed the rules file and re-added a ui file via the VS GUI to see what the add-in did differently. Well apparently either i didn't do it correctly or the add-in didn't correctly update the vcxproj file, because it still had the ui items like so:
@<ItemGroup>
<UIC Include="ui\forms\MainPane.ui" />
...
</ItemGroup>@And similarly for the resource file:
@<ItemGroup>
<QRC Include="qt_resources.qrc" />
</ItemGroup>@Where UIC and QRC are (i think) the build rules defined in the rules file.
Then looking at my test new project, the ui files were added like so:
@<ItemGroup>
<CustomBuild Include="ui\forms\MainPane.ui">
<FileType>Document</FileType>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic'ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\ui\forms\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\ui\forms\ui_%(Filename).h" "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic'ing %(Identity)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\ui\forms\ui_%(Filename).h;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\ui\forms\ui_%(Filename).h" "%(FullPath)"</Command>
</CustomBuild>
...
</ItemGroup>@In other words, it added the custom build definition on each item.
It may not be very important, but i am left wondering why the add-in does not do it in the way that custom build rule does it. It would make more sense to have just one build definition for all files of the same type (.ui, .qrc) than to put it on each and every file. It would result in a smaller project file, and would allow you to change settings that affect all files in the project. But then i guess you couldn't really do that for moc'able files (i was previously giving them a .hpp extension, as opposed to .h, to distinguish them from regular header files and allow the rules to apply to them). And you would need to store the rules file somewhere.