if you need that after closing a parent widget, a child widget is closed too, then you need add parent into ctor of a child widget.
if you need that after closing a parent widget, a child widget is closed too, then you need add parent into ctor of a child widget.
Can't you connect a signal on destruction of the child window to the close() slot in the parent? That is, something like:
Qt Code:
connect(this,SIGNAL(destroyed()),this->parent(),SLOT(close());To copy to clipboard, switch view to plain text mode
assuming, of course that the child window is a genuine Qt child object (its constructor has been passed the parent window.)
Last edited by daggilli; 14th October 2008 at 04:09.
Richard H (15th March 2017)
May be you can call qApp->quit() when some error occurs.
QCoreApplication::quit
I think that if you emit a user defined signal from the child and catch it in the parent, the you can close the parent. However, due to the parent - child relationship, the child shall also be closed when the parent closes.
This doesn't work. this->parent () returns NULL in my case.
I don't want to close the entire application so i can't use qApp->quit().
Yes, this is one of the ways of doing the job. This is specially useful if one wants to close the parent window in response to some event in the child window.
I was able to close the parent window after the child window is closed. I referred this thread:
http://www.qtcentre.org/forum/f-qt-p...sed-14009.html
So basically, once the child dialog closes, i call this->close () in the parent function and parent window is closed too.
Thanks to everyone for replying to this thread![]()
My GNU/Linux Blog:
http://funwithlinux.blogspot.com
Bookmarks