Abhishek Agarwal Abhishek Agarwal - 5 months ago 34
C++ Question

How to know child Window is destroyed form parent Window

I have a parent-child window in my Qt application. Parent class is a

named A and child class is
named B. Now I want that whenever B is closed through the 'X' button a signal is to be emitted which can be caught by a slot in class A through which I want certain functionality to be implemented. Is there a predefined signal in Qt I can use?

I want something like this:

B *b=new B;
//some code

B also has a
which I can use to detect the destroyed signal. How do I implement this? Do I need to emit a custom signal from

Edit: I don't want to destroy the object
as this would require a reallocation when I want to recreate the window
and I want to keep the parameters of

Answer Source

Your solution would only work if you set a Qt::WA_DeleteOnClose attribute to your B widget:


Another option would be to reimplement close event and emit a custom signal there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download