标题:closeEvent函数重载问题
作者:jaye_cui
日期:2016-10-20 19:01
内容:
我在MainWindow里面使用new Form生成的窗体中,重写了closeEvent函数,为什么把该窗体关闭后,closeEvent不执行?有网上网友说只有MainWindow的closeEvent才会调用,是这样吗?求大神详解
#1 [dbzhang800 10-20 20:12]
手册里说的很清楚:
void QWidget::closeEvent(QCloseEvent *event)
This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system.
#2 [jaye_cui 10-21 09:03]
问题解决了,原来是我在重写closeEvent的时候把形参弄错了,本来是void closeEvent(QCloseEvent *event),我写成了void closeEvent(QEvent *event)