سؤال

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