Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Convert Visual Studio 2017 Solution to use Qt
I have an existing large Visual Studio solution comprising a number of projects that I wish to convert from using MFC to using Qt so as to simplify a port to MacOS and (later) Linux.
I have installed Qt 5.12.8 (opensource) and the Qt addin for Visual Studio (using Visual Studio 2017 "Tools/Extensions and Updates").
Sadly I appear to be suffering from a deficit of "grey cells" today and can't work out how to use the addin to convert the projects to allow them to be used with Qt. There are two GUI projects and one Command Line projects to convert. The addin has most of the options disabled:
What am I doing wrong or not understanding?
There's no supported way to do that, but you can do it anyway :)
It's a bit wobbly process so make sure you back up your project first.
Open the .vcxproj file of the project you want to convert in a text editor and find the
<keyword>tag. Change its contents to
Save it and load that project in Visual Studio. In that Qt menu click on "Convert custom build steps to Qt/MSBuild". I know it makes no sense, don't worry :)
Now go to project properties and you should see new entry under "Configuration Properties" called "Qt Project Settings". Select it and set "Qt Installation" to desired Qt version and select wanted modules in "Qt Modules" property.
This should be enough to get you started.
This post is deleted!
Well I tried that and when I went to build the project, I got:
1>------ Build started: Project: DeepSkyStacker, Configuration: Debug x64 ------
1>Reading Qt configuration (ERROR: Qt install dir not found\bin\qmake.exe)
1>DeepSkyStacker.vcxproj : error : ERROR running qmake
1>DeepSkyStacker.vcxproj : error : qmake: (ERROR: Qt install dir not found\bin\qmake.exe)
1>DeepSkyStacker.vcxproj : error : qmake: $PWD=C:\Users\amonra\AppData\Local\Temp\4eb3h3o2.41t
1>DeepSkyStacker.vcxproj : error : qmake: The filename, directory name, or volume label syntax is incorrect.
1>DeepSkyStacker.vcxproj : error : qmake: Error creating Makefile
1>DeepSkyStacker.vcxproj : error :
1>Done building project "DeepSkyStacker.vcxproj" -- FAILED.
Which isn't what I hoped for! I expected it to just build exactly as before with the necessary changes to the project to allow use of Qt in the code (like adding rules to run moc).
So, if I have a project that's built with MFC/VS2017, how to I change it to include "stuff" from Qt so I can continue to build it (without using qmake) and slowly work though the code converting from MFC to Qt code.
Surely this is a common need.
(ERROR: Qt install dir not found\bin\qmake.exe)
This means you didn't follow what I said. Go to project settings and set Qt version and modules you want to use with your project.
Reading Qt configuration (C:\Qt\5.12.8\msvc2017_64\bin\qmake.exe) 1>TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\CL.exe" @C:\Users\amonra\AppData\Local\Temp\tmp2f7759f121cc468882a8eec9407e68e2.rsp". The parameter is incorrect. 1> 1>
@Perdrix I think these messages are separate:
Reading Qt configuration (C:\Qt\5.12.8\msvc2017_64\bin\qmake.exe)
means Qt is found and
1>TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\CL.exe" @C:\Users\amonra\AppData\Local\Temp\tmp2f7759f121cc468882a8eec9407e68e2.rsp". The parameter is incorrect.
that looks like something specific to your project. I don't think Qt has anything to do with .rsp files.
The project built 100% before I converted it as you suggested, and now it doesn't build at all :(.
The only changes that I made were the ones you proposed, so I'm rather at a loss as to how to proceed.
If converting the project to a Qt project and attempting to work on it piece by piece isn't the right approach, what is the right way/best way to take a project written for Windows MFC and convert it to use Qt ?
Grrr It was a MS snafu:
I'd set EV PreferredToolArchitecture to x64 to get round the warnings that qmake was giving about the compiler (see one of my other threads). Removing the EV allows the project to build.
PS please could I get at least +1 reputation - I've lots of questions :)