例如希望QMdiArea中的QSubWindow被关闭时,widget不被删除
QMdiArea的派生
class MyArea : public QMdiArea
{
virtual eventFiter(QObject* watched, QEvent* event)
{
if(watched.inherits("QSubWindow"))
{
if(event.type() == Qt::close)
{
this->remove((QWidgt*)watched);//并未被删除
return true;
}
}
}
return QMdiArea::eventFilter(watched,event);
}
QMdiSubWindow的派生
class QMdiSubWindow: public QMdiArea
{
virtual void closeEvent(QCloseEvent* event)
{
this->mdiArea().remove(this);
}
}