当前位置:网站首页>QT 窗体的show/exec、close/hide,调用close析构没有执行
QT 窗体的show/exec、close/hide,调用close析构没有执行
2022-06-13 11:01:00 【热爱生活热爱你】
1、show/exec
show时候只是把窗体显示出来,show后面的事件会继续执行,可以理解为非模态。
exec会把窗体显示出来,并且会暂停到这里,可以理解为模态,当窗体关闭才会执行后面的动作。
关于模态和非模态的讲解请看下面文字(感谢作者):
qt弹窗界面模态设置_求知者先的博客-CSDN博客_qt设置窗口为模态
2、close/hide
hide是隐藏窗体,不会发送任何信号。
close会隐藏窗体 ,会触发closeEvent,你可以自己重写closeEvent来控制隐藏或不隐藏,或自己的逻辑,但是默认情况下是不会触发窗体的析构函数的;如果需要触发析构函数,需要Qt::WA_DeleteOnClose标志影响窗体在内存中的状态。
如果你窗体是new出来的,系统close后迪触发窗体析构函数: 方法1:setAttribute(Qt::WA_DeleteOnClose); (如果不是new出来的,使用本方法,close可能会出现异常) 方法2: exec后,执行delete 对象即可;
不论是那种,主窗体关闭时候,都会析构销毁;
边栏推荐
- Questions and answers of the labor worker general basic (labor worker) work license in 2022
- vivo大规模 Kubernetes 集群自动化运维实践
- 宝塔中navicat连接mysql
- 【TcaplusDB知识库】Tmonitor单机安装指引介绍(一)
- Database learning notes (Chapter 16)
- Brief request process
- Multithreading starts from the lockless queue of UE4 (thread safe)
- 【TcaplusDB知识库】Tmonitor后台一键安装介绍(二)
- Go 要加个箭头语法,这下更像 PHP 了!
- 【20220526】UE5.0.2 release d11782b
猜你喜欢
随机推荐
【TcaplusDB知识库】Tmonitor后台一键安装介绍(二)
ST表学习
关于 SAP Spartacus CmsService.getComponentData 可能的优化思路
Redis相关
宝塔中查看mysql默认密码
【TcaplusDB知识库】TcaplusDB单据受理-创建游戏区介绍
Necessary for Architects: system capacity status checklist
Questions and answers of the labor worker general basic (labor worker) work license in 2022
Count the number of special subsequences (0, 1, 2) DP
Environ. Sci. Technol.(IF=9.028) | 城市绿化对大气环境的影响
Talk about MySQL indexing mechanism
Brief request process
C#/VB.NET 在Word转PDF时生成目录书签
Database learning notes (Chapter 15)
Determine the maximum match between bipartite graph and bipartite graph
Go needs to add an arrow syntax, which is more like PHP!
SSM整合初步 所得细节
Understand an article: Spark operation mode
of_ find_ compatible_ Node find all nodes
【TcaplusDB知识库】TcaplusDB运维单据介绍