Why you do not hide them? or use a signal and slot. I do not think that you can close it (this->accept(); or this->reject();) because of the parent reference. unless you take care of the parent and always set the parent to be the mainWindow. the you can use signal and slots to close it.