Important: Please read the Qt Code of Conduct -

QtWinMigrate in an MFC DLL?

  • I'm working on porting a massive MFC app over to Qt. I'm using QtWinMigrate so I can port portions of the code one at a time. I've run into an issue that I can't figure out. I have many MFC DLLs that contain UI elements. These are full blown MFC DLLs with their own CWinApp and do not have a DllMain function. If I try to include QtWinMigrate into the CWinApp like I did in the main window I get an error saying that only one application object is allowed. But if I just try to use QWinWidget inside the DLL without it then it asserts somewhere deep inside the MFC source code.

    I can export the Qt classes individually and use them in the main window just fine, but in some cases I have nested dialogs where an MFC dialog inside the DLL needs to call another dialog inside the DLL. That's when I run into the issue. I need the MFC dialogs inside the DLL to be able to call the Qt dialogs inside the DLL. This is the code I'm using to call the dialog...

    QWinWidget win(this);
    QtDialog dlg(&win);

    I've also tried using AfxGetMainWnd() in place of "this" in the QWinWidget constructor and it does the same thing.

    Does anyone know how to make this work?

Log in to reply