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. Put Qt UI to MFC application
Forum Updated to NodeBB v4.3 + New Features

Put Qt UI to MFC application

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 7.7k 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.
  • M Offline
    M Offline
    mandruk1331
    wrote on 18 Oct 2017, 08:54 last edited by
    #1

    Hello
    At the moment I'm developing an app using MFC, but the UI in MFC is not that, therefore I would like to ask if there is a way to separate the UI from qt and put it into MFC?
    Thanks in advance.

    Mandruk1331

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 18 Oct 2017, 09:39 last edited by
      #2

      Hi
      Not really possible.

      If you want to use Qt UI then why use MFC ?

      Im not sure i understand what you want.

      Mixing BOTH MFC windows/ GUI controls with Qt widgets ?
      or what is the goal ?

      M 1 Reply Last reply 18 Oct 2017, 11:29
      1
      • M mrjj
        18 Oct 2017, 09:39

        Hi
        Not really possible.

        If you want to use Qt UI then why use MFC ?

        Im not sure i understand what you want.

        Mixing BOTH MFC windows/ GUI controls with Qt widgets ?
        or what is the goal ?

        M Offline
        M Offline
        mandruk1331
        wrote on 18 Oct 2017, 11:29 last edited by
        #3

        @mrjj I want to replace the MFC UI with the Qt's UI. At the moment I'm using the I have connected the dll's to the MFC project but there is an exception in the code:

        HMODULE mod = LoadLibrary(L"qtdialog.dll");
        	int g = GetLastError();
        	if (mod) {
        	typedef BOOL(*pShowDialog)(HWND parent);
        	pShowDialog showDialog = (pShowDialog)GetProcAddress(mod, "showDialog");
        	if (showDialog)
        			showDialog(theApp.m_pMainWnd->m_hWnd); // NULL in theApp.m_pMainWnd->m_hWnd
        	FreeLibrary(mod);
        	}
        

        Mandruk1331

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 18 Oct 2017, 11:40 last edited by VRonin
          #4

          what's in qtdialog.dll?

          Normally integrating Qt and MFC hits a wall when you realise you need 2 different event loops running at the same time

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          M 1 Reply Last reply 18 Oct 2017, 11:50
          1
          • V VRonin
            18 Oct 2017, 11:40

            what's in qtdialog.dll?

            Normally integrating Qt and MFC hits a wall when you realise you need 2 different event loops running at the same time

            M Offline
            M Offline
            mandruk1331
            wrote on 18 Oct 2017, 11:50 last edited by mandruk1331
            #5

            @VRonin I have followed this tutorial (https://sites.google.com/site/nttrungmtwiki/home/it/programming/gui-programming/mfc-to-qt-migration---walkthrough) and downloaded the winmigrate source from git rep. As I understood it's a bad idea of doing such thing?

            Mandruk1331

            M 1 Reply Last reply 18 Oct 2017, 12:08
            0
            • M mandruk1331
              18 Oct 2017, 11:50

              @VRonin I have followed this tutorial (https://sites.google.com/site/nttrungmtwiki/home/it/programming/gui-programming/mfc-to-qt-migration---walkthrough) and downloaded the winmigrate source from git rep. As I understood it's a bad idea of doing such thing?

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 18 Oct 2017, 12:08 last edited by
              #6

              @mandruk1331

              Hi
              There is something i really dont get.

              If you dont use MFC, its just c++ code
              and then you can freely have Qt as GUI code.

              So what are you really trying ?

              Why use ANY MFC gui class at all ???

              Just make a qt project, (in visual studio if you want) then
              make gui in Qt and rest is just normal c++.

              The winmigrate is for porting the App , in steps.

              But you start post with
              "At the moment I'm developing an app "

              So just STOP using MFC and use Qt instead.
              why mix it ????

              M 1 Reply Last reply 18 Oct 2017, 12:21
              1
              • M mrjj
                18 Oct 2017, 12:08

                @mandruk1331

                Hi
                There is something i really dont get.

                If you dont use MFC, its just c++ code
                and then you can freely have Qt as GUI code.

                So what are you really trying ?

                Why use ANY MFC gui class at all ???

                Just make a qt project, (in visual studio if you want) then
                make gui in Qt and rest is just normal c++.

                The winmigrate is for porting the App , in steps.

                But you start post with
                "At the moment I'm developing an app "

                So just STOP using MFC and use Qt instead.
                why mix it ????

                M Offline
                M Offline
                mandruk1331
                wrote on 18 Oct 2017, 12:21 last edited by
                #7

                @mrjj Yes sorry for that. I have been developing the app a quite long time (to learn MFC ) therefore re-writing it to QT can take a lot of time. The MFC UI look old therefore I want to use the one the QT has. I had some exp. with QT, therefore to expand my knowledge I'd like to mix those two up.

                Mandruk1331

                M 1 Reply Last reply 18 Oct 2017, 12:39
                0
                • M mandruk1331
                  18 Oct 2017, 12:21

                  @mrjj Yes sorry for that. I have been developing the app a quite long time (to learn MFC ) therefore re-writing it to QT can take a lot of time. The MFC UI look old therefore I want to use the one the QT has. I had some exp. with QT, therefore to expand my knowledge I'd like to mix those two up.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 18 Oct 2017, 12:39 last edited by
                  #8

                  @mandruk1331

                  Ok if to learn, it makes sense.

                  But its not easy as both have an event loop
                  and its complicated to mix it.

                  But seems good link you found. be sure to read and fully understand all of it.

                  M 1 Reply Last reply 18 Oct 2017, 12:41
                  0
                  • M mrjj
                    18 Oct 2017, 12:39

                    @mandruk1331

                    Ok if to learn, it makes sense.

                    But its not easy as both have an event loop
                    and its complicated to mix it.

                    But seems good link you found. be sure to read and fully understand all of it.

                    M Offline
                    M Offline
                    mandruk1331
                    wrote on 18 Oct 2017, 12:41 last edited by
                    #9

                    @mrjj Yes VRonin mentioned that I will have to run 2 event loops, as I understand one will be for event handling and the other is for the UI.

                    Mandruk1331

                    M 1 Reply Last reply 18 Oct 2017, 12:43
                    0
                    • M mandruk1331
                      18 Oct 2017, 12:41

                      @mrjj Yes VRonin mentioned that I will have to run 2 event loops, as I understand one will be for event handling and the other is for the UI.

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 18 Oct 2017, 12:43 last edited by
                      #10

                      @mandruk1331

                      Yeah if the main app class is MFC it will need the normal event loop.
                      and Qt will still want one for dialog etc.

                      M 1 Reply Last reply 18 Oct 2017, 12:44
                      0
                      • M mrjj
                        18 Oct 2017, 12:43

                        @mandruk1331

                        Yeah if the main app class is MFC it will need the normal event loop.
                        and Qt will still want one for dialog etc.

                        M Offline
                        M Offline
                        mandruk1331
                        wrote on 18 Oct 2017, 12:44 last edited by
                        #11

                        @mrjj are there any books/tutorials which can help in understanding how to create the Qt UI in MFC?

                        Mandruk1331

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 18 Oct 2017, 13:17 last edited by
                          #12

                          Hi,

                          You might want to take a look at the QtWinMigrate solution of the QtSolutions module.

                          Hope it helps

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1

                          1/12

                          18 Oct 2017, 08:54

                          • Login

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