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.0k 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 13 Mar 2021, 12:27 last edited by
    #1

    Currently all our GUI components are written in MFC with visual studio 9.0 .I have no idea whether: 1) We can replace all MFC components with Qt, without changing build environment ? You answers will help me in getting started, In the mean time I have installed Qt 5 and am trying to migrate from MFC to Qt5.

    J 1 Reply Last reply 13 Mar 2021, 13:22
    0
    • W willkom
      13 Mar 2021, 12:27

      Currently all our GUI components are written in MFC with visual studio 9.0 .I have no idea whether: 1) We can replace all MFC components with Qt, without changing build environment ? You answers will help me in getting started, In the mean time I have installed Qt 5 and am trying to migrate from MFC to Qt5.

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 13 Mar 2021, 13:22 last edited by
      #2

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

      Currently all our GUI components are written in MFC with visual studio 9.0 .I have no idea whether: 1) We can replace all MFC components with Qt, without changing build environment ? You answers will help me in getting started, In the mean time I have installed Qt 5 and am trying to migrate from MFC to Qt5.

      Since you copied the question from https://stackoverflow.com/questions/1700428/transition-from-mfc-to-qt, you can copy the answer too

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

      1 Reply Last reply
      4
      • W Offline
        W Offline
        willkom
        wrote on 13 Mar 2021, 16:41 last edited by
        #3

        I tried, but the qt compiler cannot find the following files "afxwin.h", "afx.h", it only works with MFC.

        J J 2 Replies Last reply 13 Mar 2021, 20:10
        0
        • W willkom
          13 Mar 2021, 16:41

          I tried, but the qt compiler cannot find the following files "afxwin.h", "afx.h", it only works with MFC.

          J Offline
          J Offline
          JonB
          wrote on 13 Mar 2021, 20:10 last edited by
          #4

          @willkom
          Qt does not have its own compiler. You supply the compiler you want it to use. afx... are files for use with the Microsoft C++ compiler.

          1 Reply Last reply
          2
          • W willkom
            13 Mar 2021, 16:41

            I tried, but the qt compiler cannot find the following files "afxwin.h", "afx.h", it only works with MFC.

            J Offline
            J Offline
            JKSH
            Moderators
            wrote on 14 Mar 2021, 13:18 last edited by
            #5

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

            cannot find the following files "afxwin.h", "afx.h"

            Those headers are part of an external library, so you must add the library to your project. I presume you are using the Qt Creator IDE? If so, follow these steps to add external libraries to your Qt project: https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html

            Alternatively, you can use the Qt Visual Studio Add-In to use Qt libraries in Visual Studio: https://marketplace.visualstudio.com/items?itemName=TheQtCompany.QtVisualStudioTools-19123

            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 16 Mar 2021, 10:14 last edited by
              #6

              @JKSH thank for your answer but i don't wan to use Visual Studio and MFC anymore i wan to import all my MFC Visual studio projects in Qr Creator.
              i added all the necessary libraries, but that generated a lot of errors, it look like MFC framework only work in visual studio.

              J 1 Reply Last reply 16 Mar 2021, 10:16
              0
              • W willkom
                16 Mar 2021, 10:14

                @JKSH thank for your answer but i don't wan to use Visual Studio and MFC anymore i wan to import all my MFC Visual studio projects in Qr Creator.
                i added all the necessary libraries, but that generated a lot of errors, it look like MFC framework only work in visual studio.

                J Offline
                J Offline
                JonB
                wrote on 16 Mar 2021, 10:16 last edited by JonB
                #7

                @willkom
                If you don't want to use MFC any more why are you trying to import them into Creator? Can't you pull your own code across and start editing it to move away from MFC without needing to get MFC working, which is going to be a hassle?

                1 Reply Last reply
                0
                • 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 Offline
                    J Offline
                    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 Offline
                        C Offline
                        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 Offline
                                      J Offline
                                      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

                                          2/21

                                          13 Mar 2021, 13:22

                                          topic:navigator.unread, 19
                                          • Login

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