惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
雷峰网
雷峰网
V
Visual Studio Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
IT之家
IT之家
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
月光博客
月光博客
A
About on SuperTechFans
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale

博客园 - 云山漫卷

AP与网桥概念对比 QT开源社区版账号申请 Lua语法深入1 LUA语法细节 docker 报(docker0)conflicts with network、networks have same bridge name CPU架构的演进(及其背后的指令集的演进) 上下拉电阻 树莓派中可由用户修改的配置文件 Linux下vi常用操作、常用命令 Lambda表达式二例 c++ 标准库多线程 git基本操作 Makefile中3个常用自动化变量 添加.pri文件并引入QCustomPlot图表库自定义图表 QTreeWidget 样式表 Qt css颜色对照表 设置QT窗体的阴影效果 解决错误no documents matching "ui 错误解决 allocation of incomplete type ‘Ui::
删除界面上控件
云山漫卷 · 2022-05-04 · via 博客园 - 云山漫卷

删除界面上控件

删除界面上控件的注意点:

    QLayout *layout = this->ui->frameWindow->layout();
    if (layout != nullptr){
        for (int i = layout->count()-1; i >= 0; i--)    //倒序删除,reverse deleting to avoid Count changed in the middle of process
        {
            QLayoutItem* layoutItem = layout-> itemAt(i);
            layout->removeItem(layoutItem);
            if (layoutItem->widget() != nullptr)        //QLayoutItem可能包含widget(如QWidgetItem),也可能不包含widget(如QLayout、QSpacerItem)
                layoutItem->widget()->deleteLater();    //不删除会残留痕迹
        }
        delete layout;
    }

posted @ 2022-05-04 13:38  云山漫卷  阅读(126)  评论(0)    收藏  举报