首先看函數QApplication::setQuitOnLastWindowClosed(bool) ,該函數的作用是
This property holds whether the application implicitly quits when the last window is closed.
The default is true
即控制着當最后一個可視的窗口退出時候,程序是否退出,默認是是的
如果使用app.setQuitOnLastWindowClosed(false);然后當該出窗口close以后,ps -e查看,我們發現應用程序仍舊在運行中
所以當此時,如果所有的窗口都響應了close(),那么application就退出了,
如果窗口關閉,就返回TRUE,否則返回FALSE
首先給widget發送一個QCloseEvent,如果widget接受了event,就hide,如果忽略,就什么事情都不做,默認的是接受
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.
當最后一個可視窗口退出時候,信號QApplication::lastWindowClosed() 被發射,然后quit
當然也可以在某一個時刻,直接調用quit()方法來退出application
這里只是說明其略微的不同
---------------------
作者:seanyxie
來源:CSDN
原文:https://blog.csdn.net/seanyxie/article/details/5805631?utm_source=copy
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!