I have my MainWindow that open a second Window.
When I click on a button in my second window, a thread is launched and I want my thread to end when I quit my second window.
What is the signal emitted when my SecondWindow is closed ?
Thank you for your futures answers
There is no signal emitted when widgets (including QMainWindows) are closed. If a widget is set to be deleted when it is closed then you could use the following QObject signal to detect when the widget is about to be destroyed...
void destroyed(QObject *obj = Q_NULLPTR)
However this will only work if your window has the Qt::WA_DeleteOnClose flag enabled (it is not enabled by default).
Alternatively and probably more preferably you can implement the standard widget close event and emit your own signal to indicate that the window was closed:
void MainWindow::closeEvent( QCloseEvent* event )
{
emit MySignalToIndicateThatTheWindowIsClosing();
event->accept();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With