Important: Please read the Qt Code of Conduct -

Creating a QMainWindow in _tWinMain()

  • Can I create an instance of a subclassed QMainWindow in my WinMain() function and then invoke the overridden CWinApp::Run() that QMfcApp delivers?

    Or do I have to throw away WinMain and all the QMfcApp and QWinWidget stuff and just go for a standard main() that invokes QApplication::exec(). If so where do I put all the MFC/Ole/GDI initialisation stuff that's necessary for me to use MFC components that I haven't yet converted to Qt?

    Confused - yes!

  • Well, I tried it:

    		DeepSkyStacker	mainWindow;
    		if (!fileListName.isEmpty())
    			ZTRACE_RUNTIME("Set Starting File List");
    			ZTRACE_RUNTIME("Set Starting File List - ok");
    		ZTRACE_RUNTIME("Creating Main Window - ok");
    			ZTRACE_RUNTIME("Invoking Run() ");
    		//	dlg.DoModal();

    The main window opened just fine, but when I closed it, theApp.Run() didn't return as it didn't return from QMfcApp.Run().

    BOOL CDeepSkyStackerApp::Run()
    const int result = QMfcApp::run(this);
    delete qApp;
    return result;

    If I use "Break All" in the debugger at this point the call stack looks like:


    What am I doing wrong?

Log in to reply