最初在 Qt Creator 中隐藏控件 [英] Initially hidden control in Qt Creator

查看:191
本文介绍了最初在 Qt Creator 中隐藏控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让一个分组框仅在选中单选按钮时显示.
我设法通过将单选按钮的 toggled(bool) 信号连接到组合框的 setShown(bool) 插槽来做到这一点.
问题是单选按钮最初被取消选择,但组框最初显示,所以我必须选择/取消选择单选按钮以使其消失.
有没有什么方法可以使分组框最初在 Qt Creator Designer 中不可见,而无需在代码中执行此操作?

I want to make a group box shown only when a radio button is selected.
I managed to do that by connecting the toggled(bool) signal of the radio button to the setShown(bool) slot of the group box.
The problem is that the radio button is initially deselected but the group box is initially shown so I have to select/deselect the radio button to make it disappear.
Is there any way I can make the group box initially invisible in Qt Creator Designer without having to do it in code?

推荐答案

你不能.

visible 属性似乎被自动从 Qt Designer 的属性编辑器中删除,您无法将其添加回来.

The visible property seems to be voluntarily removed from the property editor of Qt Designer and you can't add it back.

您可以通过在要隐藏的小部件的节点内添加以下 XML 块来手动将属性添加到 .ui 文件:

You can add the property manually to the .ui file by adding the following XML block inside the node for the widget you want to hide:

<property name="visible">
   <bool>false</bool>
</property>

但是当您与设计者重新打开界面时,该小部件将不可见或不可移动.不过它仍然会出现在小部件层次结构中.

But the widget won't be visible or movable when you reopen the interface with the designer. It will still appear in the widget hierarchy though.

这篇关于最初在 Qt Creator 中隐藏控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆