Unsolved How to get the closed sub-window from within the CloseEvent method.
-
I have the following application:
The
CloseEvent
method code:void PSubWindow::closeEvent(QCloseEvent *event) { if(this->property("isSaved").toBool() == false){ event->ignore(); if(QMessageBox::warning(this->parent, "Changes not saved", "Would you like to save the modifiction?", QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes){ PActions::get()->saveFile(); } event->accept(); } }
I want to get the closed sub-window before destroyed from within
CloseEvent
method to save the textual contents of that window because when closing a sub-window without to be it is the active sub-window, it saves another sub-window content. -
-
Thank you, but I want two features (prevent the closing + get the closed window), but
QTabWidget::tabCloseRequested
does not have the two features. -
Then you'll likely have to subclass QTabWidget/QTabBar to fit your needs.
-
I think I found a suitable function called
eventFilter(QObject *watched, QEvent *event)
.
Do you think that function is suitable too? -
Yes, that could also be an alternative.