有关Qt closeEvent()的疑惑

Sherwei 2017-09-29 10:21:33
求解:我在closeEvent()中调用了e->accept(),然后窗口就关闭了。我就是想问一下,我的closeEvent()函数结束后,Qt调用了哪个函数,然后在这个函数中调用close()把窗口关闭了?
...全文
1603 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sherwei 2017-09-30
  • 打赏
  • 举报
回复
引用 1 楼 cuzn1024 的回复:
bool QWidget::close() [slot] Closes this widget. Returns true if the widget was closed; otherwise returns false. First it sends the widget a QCloseEvent. The widget is hidden if it accepts the close event. If it ignores the event, nothing happens. The default implementation of QWidget::closeEvent() accepts the close event. If the widget has the Qt::WA_DeleteOnClose flag, the widget is also deleted. A close events is delivered to the widget no matter if the widget is visible or not. The QApplication::lastWindowClosed() signal is emitted when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus.
原来是这样啊,我原本是这么理解的的:父类QWidget的closeEvent()里会把窗口给关掉,如果子类重新实现了closeEvent(),那么就会调用子类的closeEvent()就不会调用父类的,而如果子类的closeEvent()里什么都不做的话,那么窗口也就不会关闭了...
  • 打赏
  • 举报
回复
bool QWidget::close() [slot] Closes this widget. Returns true if the widget was closed; otherwise returns false. First it sends the widget a QCloseEvent. The widget is hidden if it accepts the close event. If it ignores the event, nothing happens. The default implementation of QWidget::closeEvent() accepts the close event. If the widget has the Qt::WA_DeleteOnClose flag, the widget is also deleted. A close events is delivered to the widget no matter if the widget is visible or not. The QApplication::lastWindowClosed() signal is emitted when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus.

16,202

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧