当前位置:网站首页>[Qt5] QT QWidget immediately appears and disappears
[Qt5] QT QWidget immediately appears and disappears
2022-07-06 03:29:00 【qq_ forty-three million four hundred and seventy-eight thousand】
Solution :
- If you use the method of generating objects on the stack , namely
QWidget w
. The object is automatically destroyed after the function is executed , Naturally, there is no . Unless it is generated in the parent function or recorded as a class member , So that the object will not be automatically destroyed after the end of the sub function . - If you allocate objects in heap memory , namely
QWidget* w = new QWidget
. The object will not be automatically destroyed after the function is executed , Don't set widget Of parent Under the circumstances ( After setting widget Not alone ), It should not disappear , But be careful about memory leaks . Be careful , Smart pointers are used here, such as sharedptr Still can't , Because after the end of the function body , Smart pointer object destruction , Destroy the objects allocated on the heap at the same time , Methods can be used 1 How to solve .
边栏推荐
- 施努卡:视觉定位系统 视觉定位系统的工作原理
- Svg drag point crop image JS effect
- 2022工作中遇到的问题四
- Exness foreign exchange: the governor of the Bank of Canada said that the interest rate hike would be more moderate, and the United States and Canada fell slightly to maintain range volatility
- Brush questions in summer -day3
- How to do function test well
- Pointer written test questions ~ approaching Dachang
- 遥感图像超分辨重建综述
- SD card reports an error "error -110 whilst initializing SD card
- Restful style
猜你喜欢
深入刨析的指针(题解)
银行核心业务系统性能测试方法
下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
[Li Kou] the second set of the 280 Li Kou weekly match
Getting started with applet cloud development - getting user search content
2022工作中遇到的问题四
Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration
3.1 detailed explanation of rtthread serial port device (V1)
【SLAM】ORB-SLAM3解析——跟踪Track()(3)
Pytorch load data
随机推荐
Performance test method of bank core business system
Tomb. Weekly update of Finance (February 7 - February 13)
数据分析——seaborn可视化(笔记自用)
Analyze menu analysis
Eight super classic pointer interview questions (3000 words in detail)
[concept] Web basic concept cognition
简述C语言中的符号和链接库
jsscript
Four logs of MySQL server layer
Force buckle 1189 Maximum number of "balloons"
NR modulation 1
Pytorch基础——(1)张量(tensor)的初始化
2.2 STM32 GPIO operation
Overview of super-resolution reconstruction of remote sensing images
Idea push rejected solution
2.2 STM32 GPIO操作
Precautions for single chip microcomputer anti reverse connection circuit
Leetcode problem solving -- 99 Restore binary search tree
Explore pointers and pointer types in depth
canvas切积木小游戏代码