Frage

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?

War es hilfreich?

Lösung

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!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top