views:

40

answers:

1

I have a QTableWidget and I can't get anything to show up in it.

The following appears in the constructor of the main window:

ui->tableWidget->setItem(0,0,new QTableWidgetItem("Item1"));
ui->tableWidget->setItem(0,1,new QTableWidgetItem("Item2"));
ui->tableWidget->setItem(0,2,new QTableWidgetItem("Item3"));

When I run the application, the table widget shows up, but the items do not.

I tried adding ui->tableWidget->insertRow(0); before the above code, but it didn't work.

A: 

Aha! I figured out what was going on... I needed to tell the control the number of rows it should have:

ui->tableWidget->setRowCount(2);
George Edison