0

I am using QtWinMigrate solution to show dialogs from my plugin dlls that are loaded in third party Mfc application. The problem is the following :

When I minimize the main window of my Mfc application, and when I restore it back again, all of my open Qt dialogs are lost. I found out that actually my Qt dialogs are destroyed i.e destructors are called.

I did some debugging and discovered the following :

When I close my Mfc main window my Qt dialog gets WM_SHOWWINDOW message with SW_PARENTCLOSING wparam parametar. Then QtWndProc is called, which for the SW_PARENTCLOSING case issues sends QHideEvent:

in QtWndProc() function in file qapplication_win.cpp line 2160

case WM_SHOWWINDOW :

if(lparam==SW_PARENTCLOSING) {
   QHideEvent e;
   qt_sendSpontaneousEvent(widget,e);
   widget->hideChildren(true); ////////////////////

and the eventFilter of QWinWidget sends DefferedDelete who deletes my dialog :

in QWinWidget.cpp in line 280

QWinWidget::eventFilter(OObject* o, QEvent* e){

    case QEvent::Hide: 

    if(w->testAtrribute(Qt::WA_DeleteOnClose)

    deleteLater(); 

}

Can someone please explain this behavior to me? This seems like bug to me .

Thanks

user152508
  • 3,053
  • 8
  • 38
  • 58
  • I'm trying to use QtWinMigrate with a plugin DLL also. While I can get a Qt Window to appear the window is completely unresponsive as if it's not getting any events (while the MFC app remains responsive). Did you ever encounter this or have an input on how to solve it? – User Mar 10 '11 at 21:52
  • I am only showing QDialog windows from my plugin dll. I am not sure if u can show QMainWindow. However check if you set the message hook appropriately. Set breakpoint in QtFilterProc in qmfcapp.cpp and see if it gets hit. This function sends the windows messages to Qt for processing. – user152508 Mar 11 '11 at 11:24
  • Also when creating the qt dialog set its parent window to be the main window of the host MFC application. – user152508 Mar 11 '11 at 11:31

1 Answers1

0

You have the answer in your question. See the documentation on WA_DeleteOnClose. You will need to call setAttribute(WA_DeleteOnClose, false) on your dialogs that you don't want deleted when they are hidden.

KillerWabbit
  • 94
  • 1
  • 1