当前位置:网站首页>【Qt5】Qt QWidget立刻出现并消失
【Qt5】Qt QWidget立刻出现并消失
2022-07-06 03:26:00 【qq_43478653】
解决方案:
- 如果采用栈上生成对象的方式,即
QWidget w
。函数执行完后对象自动销毁,自然也就没有了。除非在父函数内生成或作为类成员记录,以让子函数结束后对象不自动销毁。 - 如果采用堆内存分配对象的方式,即
QWidget* w = new QWidget
。函数执行完后对象不会自动销毁,在不设置widget的parent的情况下(设置后widget不会单独出现),应该是不会消失的,但要小心内存泄露的问题。注意,这里采用智能指针如sharedptr还是不可以,因为函数体结束后,智能指针对象销毁,伴随着堆上分配的对象的同时销毁,可以采用方法1的方式进行解决。
边栏推荐
- Some problem records of AGP gradle
- 真机无法访问虚拟机的靶场,真机无法ping通虚拟机
- 【Rust 笔记】18-宏
- Audio audiorecord binder communication mechanism
- Overview of OCR character recognition methods
- Problems encountered in 2022 work IV
- Audio-AudioRecord Binder通信机制
- Selenium share
- BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1
- StrError & PERROR use yyds dry inventory
猜你喜欢
BUAA喜鹊筑巢
如何做好功能测试
Buuctf question brushing notes - [geek challenge 2019] easysql 1
蓝色样式商城网站页脚代码
Performance analysis of user login TPS low and CPU full
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
SWC介绍
Analyze 菜单分析
[risc-v] external interrupt
施努卡:视觉定位系统 视觉定位系统的工作原理
随机推荐
Getting started with applet cloud development - getting user search content
[Li Kou] the second set of the 280 Li Kou weekly match
数据分析——seaborn可视化(笔记自用)
BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1
指针笔试题~走近大厂
SD卡報錯“error -110 whilst initialising SD card
1003 emergency (25 points), "DIJ deformation"
3.2 rtthread 串口设备(V2)详解
EDCircles: A real-time circle detector with a false detection control 翻译
多项目编程极简用例
[slam] lidar camera external parameter calibration (Hong Kong University marslab) does not need a QR code calibration board
Tidb ecological tools (backup, migration, import / export) collation
mysqldump数据备份
Redo file corruption repair
JS音乐在线播放插件vsPlayAudio.js
Cross origin cross domain request
电机控制反Park变换和反Clarke变换公式推导
这些不太会
pytorch加载数据
Safety science to | travel, you must read a guide