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. Migrate from MFC visual studio 2008 to Qt5

Migrate from MFC visual studio 2008 to Qt5

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 7 Posters 3.1k Views
  • 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.
  • W Offline
    W Offline
    willkom
    wrote on 16 Mar 2021, 11:40 last edited by
    #8

    @JonB the mingw compiler of qt creator does not work with MFC library, it is possible to set Qt creator to use MSVC++ compiler ? because i try it but i doesn't work.

    J 1 Reply Last reply 16 Mar 2021, 11:52
    0
    • W willkom
      16 Mar 2021, 11:40

      @JonB the mingw compiler of qt creator does not work with MFC library, it is possible to set Qt creator to use MSVC++ compiler ? because i try it but i doesn't work.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 16 Mar 2021, 11:52 last edited by
      #9

      @willkom said in Migrate from MFC visual studio 2008 to Qt5:

      it is possible to set Qt creator to use MSVC++ compiler ?

      Yes it is. Install Qt for MSVC first.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • W Offline
        W Offline
        willkom
        wrote on 16 Mar 2021, 17:25 last edited by
        #10

        @jsulm i can't find any qt for MSVC 2008

        J 1 Reply Last reply 16 Mar 2021, 20:38
        0
        • C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 16 Mar 2021, 17:27 last edited by
          #11

          Do you really expect to get a recent Qt version for a compiler which is more than 13 years old?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • D Offline
            D Offline
            Dan203
            wrote on 16 Mar 2021, 18:31 last edited by
            #12

            Mixing MFC and Qt can be done. I'm doing it right now. But I'm using Visual Studio with the Qt Extension not Qt Creator. Getting it to work requires a bit of a "hack". You have to include a CWinApp class with an InitInstance() function and call that from the main() function in main.cpp. Also you can't intermix MFC controls and Qt controls in a single dialog. You can only use separate MFC or Qt dialogs that are contained in their own classes. I'm only doing this because I have some MFC based classes that I need to use during development and I'm not ready to port over to pure Qt just yet. However the ultimate goal is to port the entire project to Qt. But it's a big project with millions of lines of code so I'm porting it piece by piece.

            1 Reply Last reply
            3
            • W willkom
              16 Mar 2021, 17:25

              @jsulm i can't find any qt for MSVC 2008

              J Offline
              J Offline
              JonB
              wrote on 16 Mar 2021, 20:38 last edited by
              #13

              @willkom
              Again: if you state your goal is to migrate away from MFC to Qt, why are you trying to constrain your environment (compiler) to get the MFC working with Qt? Wouldn't it be simpler not to try to do so and just pick a new Qt/compiler environment and migrate across? I just don't get it....

              D 1 Reply Last reply 16 Mar 2021, 23:27
              1
              • C Offline
                C Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on 16 Mar 2021, 22:46 last edited by
                #14

                @willkom Before you start migrating your project from MFC to Qt I would suggest to migrate from VS 9.0 to something modern, preferably VS2019. This alone will be a big task, so don't pile problems up and start with that. When you finish that you can start porting to Qt5 using the qtwinmigrate library. After that you can think of migrating to Qt6 if there's something interesting in it for you.

                There's no point switching to Qt still using VS 9.0. Qt5 does not support it (it won't even compile). The last Qt version to support it was 4.8 (I think), which is ancient at this point and already obsolete, so there's little benefit in switching to that.

                @Dan203 said:

                Also you can't intermix MFC controls and Qt controls in a single dialog

                Well that's not entirely true. You can embed Qt widgets inside native MFC windows and the other way around. I've done it and it works. It's a Frankenstein's monster and a pain in the rear to get the event delivery and focus switching right but it's doable. I'm in the same boat as you - giant project that took years to port piece by piece, so had to develop entire "framework" to allow that mixing but it's doable.

                1 Reply Last reply
                4
                • J JonB
                  16 Mar 2021, 20:38

                  @willkom
                  Again: if you state your goal is to migrate away from MFC to Qt, why are you trying to constrain your environment (compiler) to get the MFC working with Qt? Wouldn't it be simpler not to try to do so and just pick a new Qt/compiler environment and migrate across? I just don't get it....

                  D Offline
                  D Offline
                  Dan203
                  wrote on 16 Mar 2021, 23:27 last edited by
                  #15

                  @JonB In my case the project is big and migrating everything at once simply isn't feasible. Even if I wanted to do that I'd still need to link against MFC temporarily just for testing. If I didn't link MFC at all then I wouldn't even be able to debug my code until the entire project was ported, which would be essentially impossible.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    JKSH
                    Moderators
                    wrote on 17 Mar 2021, 00:32 last edited by JKSH
                    #16

                    @willkom: To summarize the advice from @Dan203 and @Chris-Kawa, you should do the migration in multiple steps:

                    1. First, port your project from Visual Studio 2008 to Visual Studio 2019
                    2. Then, install Qt 5 for MSVC 2019
                    3. Then, build the qtwinmigrate framework to use with your project: https://github.com/qtproject/qt-solutions/tree/master/qtwinmigrate

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    2
                    • W Offline
                      W Offline
                      willkom
                      wrote on 18 Mar 2021, 10:36 last edited by
                      #17

                      Thank you everyone.
                      @Chris-Kawa do I have to use the qtwinmigrate library? I just can't use the msvc_2019 compiler in qt creator 5?

                      J C 2 Replies Last reply 18 Mar 2021, 10:37
                      0
                      • W willkom
                        18 Mar 2021, 10:36

                        Thank you everyone.
                        @Chris-Kawa do I have to use the qtwinmigrate library? I just can't use the msvc_2019 compiler in qt creator 5?

                        J Online
                        J Online
                        jsulm
                        Lifetime Qt Champion
                        wrote on 18 Mar 2021, 10:37 last edited by
                        #18

                        @willkom said in Migrate from MFC visual studio 2008 to Qt5:

                        I just can't use the msvc_2019 compiler in qt creator 5?

                        Of course you can. You can't use MSVC 2008...

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        3
                        • W willkom
                          18 Mar 2021, 10:36

                          Thank you everyone.
                          @Chris-Kawa do I have to use the qtwinmigrate library? I just can't use the msvc_2019 compiler in qt creator 5?

                          C Offline
                          C Offline
                          Chris Kawa
                          Lifetime Qt Champion
                          wrote on 18 Mar 2021, 10:53 last edited by
                          #19

                          @willkom said:

                          do I have to use the qtwinmigrate library? I just can't use the msvc_2019 compiler in qt creator 5?

                          One has nothing to do with the other. You need to update VS to be able to use Qt5. There's no Qt Creator 5. There's Qt5 and Qt Creator is an IDE (a program made with Qt).

                          qtwinmigrate is unrelated and is just a convenience library that helps with the complicated embedding and event routing between MFC and Qt but you don't have to use it if you don't want to. You can do everything it does manually. It's just more work.

                          1 Reply Last reply
                          2
                          • W Offline
                            W Offline
                            willkom
                            wrote on 18 Mar 2021, 12:09 last edited by
                            #20

                            @Chris-Kawa, so using qtwinmigrate library mean convert all the MFC dependency of the project to Qt5 dependency right?

                            C 1 Reply Last reply 18 Mar 2021, 13:01
                            0
                            • W willkom
                              18 Mar 2021, 12:09

                              @Chris-Kawa, so using qtwinmigrate library mean convert all the MFC dependency of the project to Qt5 dependency right?

                              C Offline
                              C Offline
                              Chris Kawa
                              Lifetime Qt Champion
                              wrote on 18 Mar 2021, 13:01 last edited by Chris Kawa
                              #21

                              @willkom said:

                              so using qtwinmigrate library mean convert all the MFC dependency of the project to Qt5 dependency right?

                              qtwinmigrate is a stopgap solution that allows MFC and Qt to coexist in a single app and embed widgets in MFC windows so you can port all your MFC classes one by one. When you're done qtwinmigrate is no longer used and can be removed from your project.

                              So if you decide to use it the steps are:

                              • Port your app to VS2019 (still with just MFC)
                              • If you want to use Qt Creator you'll probably want to port your solution from .sln to qmake or CMake.
                              • Add qtwinmigrate to your project and use it to create a Qt event loop inside your MFC application
                              • Using qtwinmigrate start porting your MFC classes one by one to Qt
                              • When you're done remove qtwinmigrate from your project
                              • Remove MFC dependencies from your project (libs, includes etc.)
                              1 Reply Last reply
                              4

                              17/21

                              18 Mar 2021, 10:36

                              • Login

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