简体   繁体   English

Qt-如何清除QGroupBox UI对象的内容

[英]Qt - How to clear the contents of a QGroupBox UI object

This question is pretty straightforward: I have a QGroupBox object that initially has a QTableView inside of it. 这个问题非常简单:我有一个QGroupBox对象,该对象最初具有一个QTableView。 When the user clicks a certain button, I need the QTableView object to be removed, leaving just an empty QGroupBox. 当用户单击某个按钮时,我需要删除QTableView对象,仅留下一个空的QGroupBox。 I know I can use addWidget() to create a table inside of the QGroupBox, but after looking around the docs for a while I'm having a hard time finding a similar function to remove widgets. 我知道我可以使用addWidget()在QGroupBox内创建一个表,但是在查找文档一段时间后,我很难找到一个类似的功能来删除小部件。 Is there any way to do this? 有什么办法吗? Thanks! 谢谢!

Note: I just found that there's an isEmpty() function related to the groupBox->layout(), is there maybe something similar with the layout to access the widgets if that function returns false? 注意:我刚刚发现有一个与groupBox-> layout()相关的isEmpty()函数,如果该函数返回false,是否可能与布局相似以访问小部件?

您可以使用QTableView :: hide()将其从QGroupBox中隐藏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM