Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Convert Visual Studio 2017 Solution to use Qt
Forum Updated to NodeBB v4.3 + New Features

Convert Visual Studio 2017 Solution to use Qt

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 5.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    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:

    0ee7c009-2fe9-4ffb-bfa9-73e231631f33-image.png

    What am I doing wrong or not understanding?

    Thanks, David

    1 Reply Last reply
    1
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      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 QtVS_v302.
      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.

      PerdrixP 1 Reply Last reply
      6
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Chris KawaC Chris Kawa

          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 QtVS_v302.
          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.

          PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by
          #4

          @Chris-Kawa said in Convert Visual Studio 2017 Solution to use Qt:

          QtVS_v302

          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.
          D.

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #5

            @Perdrix said in Convert Visual Studio 2017 Solution to use Qt:

            (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.

            1 Reply Last reply
            0
            • PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by
              #6

              @Perdrix said in Convert Visual Studio 2017 Solution to use Qt:

              QtVS_v302

              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>
              
              Chris KawaC 1 Reply Last reply
              0
              • PerdrixP Perdrix

                @Perdrix said in Convert Visual Studio 2017 Solution to use Qt:

                QtVS_v302

                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>
                
                Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by Chris Kawa
                #7

                @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.

                1 Reply Last reply
                0
                • PerdrixP Offline
                  PerdrixP Offline
                  Perdrix
                  wrote on last edited by
                  #8

                  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 ?

                  Thanks
                  David

                  1 Reply Last reply
                  0
                  • PerdrixP Offline
                    PerdrixP Offline
                    Perdrix
                    wrote on last edited by
                    #9

                    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 :)

                    David

                    1 Reply Last reply
                    1
                    • E edvid referenced this topic on

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved