Qt的Window Close与程序退出

本文探讨了QApplication的quitOnLastWindowClosed属性,该属性默认设置为true,导致当最后一个可见主窗口关闭时程序退出。在遇到隐藏主窗口并显示文件对话框后程序意外退出的问题时,通过设置quitOnLastWindowClosed属性为false,可以防止程序在文件对话框关闭时退出,确保主窗口能够正确重新显示。
摘要由CSDN通过智能技术生成

先写下重点

QApplication::quitOnLastWindowClosed

以下是对于QApplication中此属性的解释:
This property holds whether the application implicitly quits when the last window is closed.

The default is true.

If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) is closed.

quitOnLastWindowClosed这个属性决定最后一个window关闭时,程序是否会退出(quick)。此属性的默认值为true。如果为true,程序会在最后一个可视主窗口(比如:一个没有parent的window)关闭时退出。

问题来了

下面是一个例子:

/*mainwindow.cpp*/
#include "mainwindow.h"
#inc
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值