c++ - Qt从其他Layout中移除Layout

标签 c++ qt qlayout

When I use delete layout_newInfo; layout_main->update() happends this.如何在运行时(按下按钮)从 layout_main 中删除 layout_newInfo?

I need get this back after pressing button (next image)

Delete orange section (layout_newInfo) by pressing button Add Component

我试过的代码:

    QLayout *layout = this->layout();

    QLayoutItem *item;
    while ((item = layout->takeAt(0)) != 0)
        layout->removeItem (item);
    delete layout_newInfo;
    layout_main->update();

最佳答案

你到底想达到什么目的? 如果你想显示/隐藏现在在 layout_newInfo 中的小部件,那么 不要使用布局。使用放置在 layout_main(垂直布局)中的小部件,它本身具有 newInfo 项目和布局,然后根据需要在小部件上使用 setVisible(true/false)。

关于c++ - Qt从其他Layout中移除Layout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42013674/

相关文章:

C++ SFINAE with CRTP, G++ 编译错误

c - 尝试研究 MPEG Layer-III 编码器 - 在“错误”之前获取 "expected ' =', ' ,', ' ;', ' asm' 或 '__attribute__'

c++ - 无法在 Qt 中执行 ftp ConnectToHost

c++ - 如何修复 QHBoxLayout 项目大小并向 QHBoxLayout 中的每个项目添加下拉列表

c++ - 将右值引用传递给右值引用参数时发生错误

c++ - 如何在不违反 MISRA C++ 2008 咨询规则 5-2-10 的情况下使用 std::transform?

c++ - 从 C++ 检测静态添加的 QML 子项

c++ - Qt中线程间通信的实现

Python PyQt4 从 qlayout 创建 pdf

python - 如何在没有可见空白的情况下扩展/缩小 QTable View