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"); mainWindow.setFileListName(fileListName); ZTRACE_RUNTIME("Set Starting File List - ok"); } mainWindow.show(); ZTRACE_RUNTIME("Creating Main Window - ok"); try { ZTRACE_RUNTIME("Invoking Run() "); theApp.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()
{
ZFUNCTRACE_RUNTIME();
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?
Thanks
David