|
1Qter豆
把Mainwindow的closeEvent()事件处理器重新编写为一个空函数,为什么还照样能关闭窗口呢?
在我看来,closeEvent()事件处理器的工作就是把MainWindow窗口隐藏(或者销毁),但我重写定义了closeEvent(),函数里面什么也没写,没有任何代码.我想再点叉叉的时候肯定MainWindow窗口不会有任何反应,但没想到,窗口照样关闭了.这是为什么呢?难道我新定义的closeEvent()压根就没执行?
|
最佳答案
查看完整内容
有些问题是可以找文档解决的。。。请按f1
By default, the event is accepted and the widget is closed. You can reimplement this function to change the way the widget responds to window close requests. For example, you can prevent the window from closing by calling ignore() on all events.
|