Hello, I'm trying to interface with a win32 app with a dll written using qt. All I'm trying to do for now is making a modeless QDialog display. I'm following the examples here: http://qt.nokia.com/products/appdev/...s/qtwinmigrate

Here is the code for my DLL entry:
Qt Code:
  1. BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
  2. {
  3. static bool ownApplication = FALSE;
  4.  
  5. if ( fdwReason == DLL_PROCESS_ATTACH )
  6. {
  7. ownApplication = QMfcApp::pluginInstance( hInstance );
  8.  
  9. char buffer[512];
  10. sprintf( buffer, "Creating MFC App - %d\n", ownApplication );
  11. OutputDebugStringA( buffer );
  12. }
  13. if ( fdwReason == DLL_PROCESS_DETACH && ownApplication )
  14. {
  15. OutputDebugString( TEXT("Deleting MFC App\n") );
  16. ownApplication = FALSE;
  17. delete qApp;
  18. }
  19.  
  20. return (TRUE);
  21. }
To copy to clipboard, switch view to plain text mode 

To test that events are surely not being processed, I devised a test using this QDialog I wrote:
Qt Code:
  1. class TestDialog : public QDialog
  2. {
  3. public:
  4. TestDialog( QWidget* pParent ) : QDialog( pParent, Qt::WindowStaysOnTopHint )
  5. {
  6. OutputDebugString( TEXT("Creating Test Dialog\n") );
  7.  
  8. setWindowTitle( "This is a test" );
  9. resize( 800, 600 );
  10. setAttribute( Qt::WA_DeleteOnClose );
  11. setModal( false );
  12. show();
  13. close();
  14. }
  15.  
  16. ~TestDialog()
  17. {
  18. // If Events are being processed, this should be outputted
  19. OutputDebugString( TEXT("Shutting Down Test Dialog\n") );
  20. }
  21. };
To copy to clipboard, switch view to plain text mode 

It is very simple, since I am setting the WA_DeleteOnClose flag, it should delete the dialog in the next event update after it has been closed. If events are being updated, the debugger should output that it is shutting down the Test Dialog. Here is the code I used to test it:

Qt Code:
  1. QWinWidget* pWinWidget = new QWinWidget( hParentWnd );
  2. pWinWidget->center();
  3.  
  4. // As a test to see if events work, see if this deletes itself (it doesn't)
  5. TestDialog* pTestDialog = new TestDialog( pWinWidget );
  6.  
  7. // if this is uncommented, it gets deleted fine (events are processed)
  8. //qApp->exec();
To copy to clipboard, switch view to plain text mode 

The following code should work if events are being processed, however the destructor of TestDialog never gets called. When I call qApp->exec() manually though, the destructor does get called and the QDialog events all work perfectly. Being that this is a DLL into a win32 application, you can imagine how qApp->exec() takes over the message handling so this is not a good solution (for example, keyboard no longer works on the original win32 application). According to the docs, QMfcApp:: pluginInstance should be able to integrate into the message loop properly. Am I doing something wrong here?