문제

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