[Qt-interest] Mdi area subwindow closed event invoke in main window

John McClurkin jwm at nei.nih.gov
Mon Aug 16 14:10:16 CEST 2010


Radiceski, Darko wrote:
>  
> **
> *Hi all,*
> ** 
> *I hope someone can help me with the following question:*
> ** 
> *I have a QT Gui application which has a QMdi area to which i add 
> widgets as sub windows:*
> ** 
> 
> *_mMyDialog = new MyWidget();*
> 
> *_mMyDialog->setAttribute(Qt::WA_DeleteOnClose);*
> 
> **
> 
> *_mMdiArea->addSubWindow(_mMyDialog );*
> 
> *In the Widget that is now a subwindow to the mdi are i have a button 
> which when clicked i would like to close the widget/sub window and also 
> raise an event in the MainWindow that created the widget/subwindow that 
> will tell me that my close button has been clicked.*
> 
> *What is the best way to achieve that? In a nutshell i would like to 
> know when the subwindow is closed.*
> 
> *I have tried installing an event filter on the subwindow/widget and in 
> the event filter monitoring for the *
> 
> *case QEvent::Close:*
> 
> *That does call the event when i close the widget but also gets invoked 
> by close on main window and so on. *
> 
> *Also i have noticed that this event gets called twice even if i check 
> the type of qobject *
> 
> *Any advice on this?*
> 
> *Thank you for your help.*
> 
>  
> Dan

You might try emitting a signal from your dialog when it closes. Connect 
this signal to a slot in the main window which does whatever you need to 
do when the dialog closes.



More information about the Qt-interest-old mailing list