当前位置:网站首页>【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的方式进行解决。
边栏推荐
- [risc-v] external interrupt
- Brush questions in summer -day3
- BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1
- Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration
- Polymorphic day02
- 1.16 - 校验码
- 施努卡:视觉定位系统 视觉定位系统的工作原理
- jsscript
- Lua uses require to load the shared library successfully, but the return is Boolean (always true)
- 下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
猜你喜欢
随机推荐
下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
jsscript
Redis SDS principle
SD卡报错“error -110 whilst initialising SD card
Svg drag point crop image JS effect
Derivation of anti Park transform and anti Clarke transform formulas for motor control
教你用Pytorch搭建一个自己的简单的BP神经网络( 以iris数据集为例 )
Distributed service framework dobbo
SAP ALV color code corresponding color (finishing)
Leetcode problem solving -- 98 Validate binary search tree
Performance analysis of user login TPS low and CPU full
施努卡:什么是视觉定位系统 视觉系统如何定位
八道超经典指针面试题(三千字详解)
蓝色样式商城网站页脚代码
An article about liquid template engine
JS music online playback plug-in vsplayaudio js
Pelosi: Congress will soon have legislation against members' stock speculation
指针笔试题~走近大厂
Deep parsing pointer and array written test questions
Yyds dry inventory what is test driven development








