Initially hidden control in Qt Creator

眉间皱痕 提交于 2019-11-28 11:53:36

You can't.

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

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.

You can try playing round with the Properties (look at setHidden), but it's much easier to do it in the code.

So you'd do:

ui setup code
ui->groupBox->setHidden(true)

radio button slot
if true ui->groupBox->setHidden(false)
else if false ui->groupBox->setHidden(true)

That's the easiest way really, I've never had much luck with adding properties in Designer that Qt already uses.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!