The problem is that you are not properly reimplementing closeEvent() in your MdiChild class when you are deriving from QMdiSubWindow. Your MdiChild::closeEvent() is overriding QMdiSubWindow::closeEvent(). Obviously, when you are deriving from QTextEdit it doesn't. To make it work you need to add the following to MdiChild::closeEvent():
{
if (parentWidget() && testAttribute(Qt::WA_DeleteOnClose)) {
}
event->accept();
}
void MdiChild::closeEvent(QCloseEvent *event)
{
if (parentWidget() && testAttribute(Qt::WA_DeleteOnClose)) {
QChildEvent childRemoved(QEvent::ChildRemoved, this);
QApplication::sendEvent(parentWidget(), &childRemoved);
}
event->accept();
}
To copy to clipboard, switch view to plain text mode
Really, there is no need to reimplement closeEvent() unless you are doing more than accepting the event. Your stripped down code should work without it derived from either class.
Bookmarks