質問

If I create a new QTableWidgetItem and insert/set into a cell on a QTableWidget that already has an existing item, is the previous itemy deleted or will there be a memory leak? Do I need to retrieve the existing item and change its properties?

役に立ちましたか?

解決

When you insert a QTableWidgetItem into a QTableWidget using QTableWidget::setItem() the table takes ownership of the item, which means that it will manage it for you. If you call setItem() for a column and row that already has an item, the table will delete the old item for you. So no memory leak. You're safe!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top