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. LInk Qt framework to an MFC project
Forum Updated to NodeBB v4.3 + New Features

LInk Qt framework to an MFC project

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 2 Posters 3.9k Views 1 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 29 Oct 2017, 16:59 last edited by
    #1

    Hello, I have compiled the source of the Qt framework using the visual studio compiler, linked everything in the settings dll, libs and headers, and after I tried to create a simple message box in the MFC project but had no luck, the compiler shows this error: error LNK2019 unresolved external symbol... (link error). Not sure why it show me this error because the dll and libs are set in the project properties. Can you help me out? Thanks in advance

    Mandruk1331

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

      Hi
      it would be helpful if you show the actual linker errors.

      And why an MFC project?
      That normally do not link to the needed Qt dlls.

      Also why did you compiled your own Qt?
      Is is static or what is special about it?

      M 1 Reply Last reply 29 Oct 2017, 17:23
      0
      • M mrjj
        29 Oct 2017, 17:18

        Hi
        it would be helpful if you show the actual linker errors.

        And why an MFC project?
        That normally do not link to the needed Qt dlls.

        Also why did you compiled your own Qt?
        Is is static or what is special about it?

        M Offline
        M Offline
        mandruk1331
        wrote on 29 Oct 2017, 17:23 last edited by mandruk1331
        #3

        @mrjj
        Error 2 error LNK2019: unresolved external symbol "_declspec(dllimport) public: virtual __thiscall QMessageBox::~QMessageBox(void)" (__imp??1QMessageBox@@UAE@XZ) referenced in function "public: virtual void * __thiscall QMessageBox::`scalar deleting destructor'(unsigned int)" (??_GQMessageBox@@UAEPAXI@Z)

        It's just for learning. I have an MFC old project (used it for learning MFC) and now I just want to use the Qt ui in MFC project, to learn something new. No, the application is not static. So compiling was not a good idea(
        in the InitInstance fucntion (MFC) I'm just trying to create a QMessageBox: QMessageBox *p = new QMessageBox

        Mandruk1331

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 29 Oct 2017, 17:29 last edited by
          #4

          Hi
          Ok seems you are not linking to the Qt dlls.
          Also how will you handle the event loop?
          Do you create a QApplication object also?

          Mixed MFC and Qt might be really hard.

          M 1 Reply Last reply 29 Oct 2017, 17:31
          1
          • M mrjj
            29 Oct 2017, 17:29

            Hi
            Ok seems you are not linking to the Qt dlls.
            Also how will you handle the event loop?
            Do you create a QApplication object also?

            Mixed MFC and Qt might be really hard.

            M Offline
            M Offline
            mandruk1331
            wrote on 29 Oct 2017, 17:31 last edited by mandruk1331
            #5

            @mrjj No I'm not creating a QApplication object. Do I have to create it in order to make a test QMesssageBox?
            I red that creating a secondary thread solves the issue, and also I checked that I will have to re-write the MFC signals so that Qt UI would be able to catch them. But in fact I do link to them, In visual studio I set the Reference path to the Qt\bin folder, also I have installed Qt visual studio plugin

            Mandruk1331

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 29 Oct 2017, 17:38 last edited by
              #6

              Hi
              Yep you need QApp
              alt text

              The visual studio plugin is not ment for MFC projects. not sure it
              work with that. never tried.

              The error says its not linked. So check compiler output etc and see if you can spot something.

              M 1 Reply Last reply 29 Oct 2017, 17:47
              0
              • M mrjj
                29 Oct 2017, 17:38

                Hi
                Yep you need QApp
                alt text

                The visual studio plugin is not ment for MFC projects. not sure it
                work with that. never tried.

                The error says its not linked. So check compiler output etc and see if you can spot something.

                M Offline
                M Offline
                mandruk1331
                wrote on 29 Oct 2017, 17:47 last edited by
                #7

                @mrjj that's a run-time error. And I have a compile time, I mean that even If i'll create a Qapplication object nothing changes. Why it does not see the dll? Have you tried to connect Qt to MFC? Thanks in advance.

                Mandruk1331

                M 1 Reply Last reply 29 Oct 2017, 17:53
                0
                • M mandruk1331
                  29 Oct 2017, 17:47

                  @mrjj that's a run-time error. And I have a compile time, I mean that even If i'll create a Qapplication object nothing changes. Why it does not see the dll? Have you tried to connect Qt to MFC? Thanks in advance.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 29 Oct 2017, 17:53 last edited by mrjj
                  #8

                  That is what happens if i make a msg box before the application.
                  You will get the same if it linked and ran.

                  Sadly i never tried to mix MFC and Qt as what would be the point?
                  Both are for GUI so one is enough.

                  But i understand you do it for learning. I dont have visual studio IDE so cannot tell you
                  if you have added it to the right place.
                  http://www.technical-recipes.com/2012/how-to-link-dlls-to-c-projects/

                  You could post some images of the dialogs involved and hope that someone can spot
                  what is wrong.

                  M 2 Replies Last reply 29 Oct 2017, 18:50
                  0
                  • M mrjj
                    29 Oct 2017, 17:53

                    That is what happens if i make a msg box before the application.
                    You will get the same if it linked and ran.

                    Sadly i never tried to mix MFC and Qt as what would be the point?
                    Both are for GUI so one is enough.

                    But i understand you do it for learning. I dont have visual studio IDE so cannot tell you
                    if you have added it to the right place.
                    http://www.technical-recipes.com/2012/how-to-link-dlls-to-c-projects/

                    You could post some images of the dialogs involved and hope that someone can spot
                    what is wrong.

                    M Offline
                    M Offline
                    mandruk1331
                    wrote on 29 Oct 2017, 18:50 last edited by
                    #9

                    @mrjj at first I'll try to link Qt libs to a console application, and after will continue with MFC

                    Mandruk1331

                    1 Reply Last reply
                    0
                    • M mrjj
                      29 Oct 2017, 17:53

                      That is what happens if i make a msg box before the application.
                      You will get the same if it linked and ran.

                      Sadly i never tried to mix MFC and Qt as what would be the point?
                      Both are for GUI so one is enough.

                      But i understand you do it for learning. I dont have visual studio IDE so cannot tell you
                      if you have added it to the right place.
                      http://www.technical-recipes.com/2012/how-to-link-dlls-to-c-projects/

                      You could post some images of the dialogs involved and hope that someone can spot
                      what is wrong.

                      M Offline
                      M Offline
                      mandruk1331
                      wrote on 30 Oct 2017, 11:31 last edited by mandruk1331
                      #10

                      @mrjj did you link Qt to a Visual Studio console project? If yes how did you do that, because I'm having problems with it. Thank you
                      UPD: got it working.
                      But receiving this error:
                      This application failed to start because it could not find or load the Qt platform plugin "windows"
                      in "".

                      Mandruk1331

                      M 1 Reply Last reply 30 Oct 2017, 11:34
                      0
                      • M mandruk1331
                        30 Oct 2017, 11:31

                        @mrjj did you link Qt to a Visual Studio console project? If yes how did you do that, because I'm having problems with it. Thank you
                        UPD: got it working.
                        But receiving this error:
                        This application failed to start because it could not find or load the Qt platform plugin "windows"
                        in "".

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 30 Oct 2017, 11:34 last edited by
                        #11

                        @mandruk1331

                        Yes the link shows how the author links a dlls to his project.
                        But its 2010 VS so dialog might have changed.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 30 Oct 2017, 11:35 last edited by
                          #12

                          @mandruk1331 said in LInk Qt framework to an MFC project:

                          This application failed to start because it could not find or load the Qt platform plugin "windows"

                          That is because it cant find the dlls.
                          very normal case when people click the .exe outside of creator.

                          M 1 Reply Last reply 30 Oct 2017, 12:24
                          0
                          • M mrjj
                            30 Oct 2017, 11:35

                            @mandruk1331 said in LInk Qt framework to an MFC project:

                            This application failed to start because it could not find or load the Qt platform plugin "windows"

                            That is because it cant find the dlls.
                            very normal case when people click the .exe outside of creator.

                            M Offline
                            M Offline
                            mandruk1331
                            wrote on 30 Oct 2017, 12:24 last edited by
                            #13

                            @mrjj I have connected Qt to MFC. Thank you! It now compiles and works

                            Mandruk1331

                            1 Reply Last reply
                            1

                            1/13

                            29 Oct 2017, 16:59

                            • Login

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