开发者

Deleting QWinWidget

开发者 https://www.devze.com 2022-12-08 11:52 出处:网络
I am using mfc to Qt migration and I am showing Qt dialogs in my Mfc app. Is it Ok to deleteLater QWinWidget in its winEvent handler?

I am using mfc to Qt migration and I am showing Qt dialogs in my Mfc app. Is it Ok to deleteLater QWinWidget in its winEvent handler? The thing is that I want all of my open Qt dialogs in My Mfc application to be automatically deleted when the main mfc window is closed. Since WM_DESTROY will be sent for all child windows ( and the Qt widgets too) 开发者_StackOverflow社区So I added the following code in QwinWidget winEvent handler :

QWinWidget::winEvent(MSG * message, long * result)
       {
                 ........
                 if(message->message == WM_DESTROY )
                     deleteLater();
                 return false;
       }

Can someone comment this Thanks


Strictly regarding the safety of the deleteLater() call, it is usually safe to do inside a function running inside that class. The object won't be deleted until control is back into the event loop functions. The only potential problems I can see involve multi-threaded code, which likely wouldn't be the case for a widget with it's event handlers.

0

精彩评论

暂无评论...
验证码 换一张
取 消