QTableWidgets 内的单元格小部件在清理时会被删除吗?
假设我用按钮填充 QTableWidget
的一些单元格:
ui->table->setCellWidget (i, 2, new QPushButton ("Details"));
稍后我将它们全部刮掉并再次执行:
ui->table->clear();
这些按钮会被自动删除吗?或者我是否需要存储它们的列表并手动删除?另外,我是否需要为每个按钮指定父级,如下所示:QPushButton ("Details", ui->table)
?
Suppose I fill some cells of a QTableWidget
with buttons:
ui->table->setCellWidget (i, 2, new QPushButton ("Details"));
Just a little bit later I scratch them all and do it again:
ui->table->clear();
Will this buttons get deleted automagically? Or do I need to store a list of them and delete manually? Also, Do I need to specify parent for every button like this: QPushButton ("Details", ui->table)
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
表格小部件拥有该小部件的所有权。 文档指出:
您也不需要在创建时指定父级,这将是由 tablewidget 进行相应设置。
The table widget takes ownership of the widget. The documentation states this:
You also don't need to specify a parent on creation, that will be set by the tablewidget accordingly.