how to remove Item in Qtablewidget?
-
wrote on 15 Dec 2015, 01:44 last edited by ForestPoem
Hi. Guys
my source code ↓
ui->tableWidget->setItem(0,7,new QTableWidgetItem(QString::number(3)));
ui->tableWidget->item(0,7)->setTextAlignment(Qt::AlignCenter);my way this.
delete ui->tableWidget->item(0,7);
If this memory is free?
If not let me know any other method.
-
Hi. Guys
my source code ↓
ui->tableWidget->setItem(0,7,new QTableWidgetItem(QString::number(3)));
ui->tableWidget->item(0,7)->setTextAlignment(Qt::AlignCenter);my way this.
delete ui->tableWidget->item(0,7);
If this memory is free?
If not let me know any other method.
wrote on 15 Dec 2015, 04:48 last edited by@ForestPoem
May be deleting the pointer directly as mentioned here . -
When you set the item, The table takes ownership of the item. So just deleting the tableWidget should satisfy. If you want to selectively delete, what you are doing should be good enough.
3/3