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
Forum Updated to NodeBB v4.3 + New Features

Migrate from MFC visual studio 2008 to Qt5

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 7 Posters 3.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.
  • W willkom

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

    JKSHJ Offline
    JKSHJ Offline
    JKSH
    Moderators
    wrote on 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 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.

      JonBJ 1 Reply Last reply
      0
      • W willkom

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

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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 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.

          jsulmJ 1 Reply Last reply
          0
          • W willkom

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

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on 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 last edited by
              #10

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

              JonBJ 1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 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 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

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

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on 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
                    1
                    • Chris KawaC Online
                      Chris KawaC Online
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on 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
                      • JonBJ JonB

                        @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 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
                        • JKSHJ Offline
                          JKSHJ Offline
                          JKSH
                          Moderators
                          wrote on 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 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?

                            jsulmJ Chris KawaC 2 Replies Last reply
                            0
                            • W willkom

                              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?

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 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

                                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?

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

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

                                  Chris KawaC 1 Reply Last reply
                                  0
                                  • W willkom

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

                                    Chris KawaC Online
                                    Chris KawaC Online
                                    Chris Kawa
                                    Lifetime Qt Champion
                                    wrote on 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

                                    • Login

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