AndresBarbaRoja
28th June 2011, 17:41
Good day,
I'm trying to edit some QTableWidgetItem values and currently this is what I'm doing
QTableWidgetItem *temp = new QTableWidgetItem("String 1");
QTableWidgetItem *power = new QTableWidgetItem("String 2");
QTableWidgetItem *dutyCycle = new QTableWidgetItem("String 3");
QString mnemo = "String";
for(int i=0;i<29;i++)
{
QTableWidgetItem * head = ui->tLines_tableWidget->verticalHeaderItem(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.
I'm trying to edit some QTableWidgetItem values and currently this is what I'm doing
QTableWidgetItem *temp = new QTableWidgetItem("String 1");
QTableWidgetItem *power = new QTableWidgetItem("String 2");
QTableWidgetItem *dutyCycle = new QTableWidgetItem("String 3");
QString mnemo = "String";
for(int i=0;i<29;i++)
{
QTableWidgetItem * head = ui->tLines_tableWidget->verticalHeaderItem(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.