Editing a QTableWidgetItem and memory leaks
Good day,
I'm trying to edit some QTableWidgetItem values and currently this is what I'm doing
Code:
for(int i=0;i<29;i++)
{
if (head->text()==mnemo)
{
ui->tLines_tableWidget->setItem(i,0,temp);
ui->tLines_tableWidget->setItem(i,2,dutyCycle);
ui->tLines_tableWidget->setItem(i,3,power);
break;
}
}
My question is, what happens with the item that i'm replacing? I create the new items with "new" but i never delete them, so do i have a memory leak here?
If i'm losing memory here, how coud i avoid that?
Thanks in advance,
A.G.
Re: Editing a QTableWidgetItem and memory leaks
http://doc.qt.nokia.com/4.7/qtablewidget.html#setItem
Note that "The table takes ownership of the item." This means that the table is responsible for deleting the item at the appropriate time.
If, for some reason, you want to get the old item back and manage it yourself use "takeItem".