Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我创建一个新项目QTableWidgetItem并将其插入/设置到一个QTableWidget已经有现有项目的单元格中,那么之前的项目是否会被删除或者是否会出现内存泄漏?我是否需要检索现有项目并更改其属性?
QTableWidgetItem
QTableWidget
当您使用表将 aQTableWidgetItem插入 a时,该表将获得该项目的所有权,这意味着它将为您管理它。如果您调用已有项目的列和行,该表将为您删除旧项目。所以没有内存泄漏。你安全了!QTableWidgetQTableWidget::setItem()setItem()
QTableWidget::setItem()
setItem()