0

I was experimenting with the following code

QTableWidgetItem* item_a= new QTableWidgetItem("1");
QTableWidgetItem* item_b= new QTableWidgetItem("2");
QTableWidgetItem* item_c= new QTableWidgetItem("3");
ui.tableWidget->setItem(0,0,item_a); 
ui.tableWidget->setItem(0,1,item_b); 
ui.tableWidget->setItem(0,2,item_c); 

    item_c= new QTableWidgetItem("5"); //Is there anyway to update the table. 

I changed the value of item_c however the change does not show in the table any way I could update it without calling the setITem method ?

MistyD
  • 16,373
  • 40
  • 138
  • 240

1 Answers1

4

You don't change the value of item_c. You are creating a new QTableWidgetItem.

If you want to change the value, you need to use QTableWidgetItem::setText() :

item = table->item( 2, 0); 
item->setText("5");
Dimitry Ernot
  • 6,256
  • 2
  • 25
  • 37