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. Creating a QMainWindow in _tWinMain()

Creating a QMainWindow in _tWinMain()

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 243 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • PerdrixP Offline
      PerdrixP Offline
      Perdrix
      wrote on last edited by Perdrix
      #2

      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:

      241eac15-65d0-4e1c-a69c-cccfef89ffaa-image.png

      What am I doing wrong?
      Thanks
      David

      1 Reply Last reply
      0

      • Login

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