Tuesday, November 29, 2016

Qt5Package Extension and Win32/x64 Configurations in VS 2015

I may be using this awesome Visual Studio 2015 extension incorrectly; however, whenever I import a Qt Creator PRO file into Visual Studio using it, I get the default Qt configuration which is my x64 config.

When I go to add a Win32 Configuration, I get errors about how "There's no Qt version assigned" and it instructs me to change the Qt version.  The problem with that, is that when I try to do this via the Qt properties on the project the extension tells me "Value cannot be null. Parameter name: qtVersion."

I beat my head against the wall a bit trying to fix this and none of the online suggestions solved my problems until I found a 'several pages in' post saying to do the following:

Open your newly created project's .vcxproj file in a text editor, scroll down (usually near the very bottom) until you find some user properties for the extension.

In my project they were found in the section (this screenshot shows the location as well as the fix):

(Click on image to expand)

In my project file, before I edited the UserProperties element, there was no name/value pair for Qt5Version_x0020_Win32 - the entry only had the value for x64.

Knowing that I had configured the extension with a Win32 version with the name "Qt 5.6 x86" I added the missing name/value pair, saved the project file, re-opened it in Visual Studio and was successfully able to build.

The string YOU use for the value of Qt5Version_x0020_Win32  or Qt5Version_x0020_x64 will be dependent upon how you have configured your extension.  For example, if you have not yet defined a Qt version that points to an x86/Win32 version of Qt - you won't be able to reference it from the project file.

You may have the reverse of my problem in that your default Qt installation referenced by the extension is the x86/Win32 version of Qt.  In that case, you'll be missing the other value (which I already had.)  Just use the same process and you should be fine.

Hope this helps!