//tableWidget
ui->tableWidget->setColumnCount(3);//五行三列
ui->tableWidget->setRowCount(5);

QStringList headers;
headers << "ID" << "姓名" << "年龄" << "**";
ui->tableWidget->setHorizontalHeaderLabels(headers);//设置标题 //设置数据
ui->tableWidget->setItem(0, 0, new QTableWidgetItem(QString("1")));//行索引和列索引
ui->tableWidget->setItem(1, 0, new QTableWidgetItem(QString("2")));//第二行第一列
ui->tableWidget->setItem(2, 0, new QTableWidgetItem(QString("3")));
ui->tableWidget->setItem(3, 0, new QTableWidgetItem(QString("4")));
ui->tableWidget->setItem(4, 0, new QTableWidgetItem(QString("5")));
ui->tableWidget->setItem(0, 1, new QTableWidgetItem(QString("张三")));
ui->tableWidget->setItem(1, 1, new QTableWidgetItem(QString("李四")));
ui->tableWidget->setItem(2, 1, new QTableWidgetItem(QString("王五")));
ui->tableWidget->setItem(0, 2, new QTableWidgetItem(QString("20")));
ui->tableWidget->setItem(1, 2, new QTableWidgetItem(QString("66")));
ui->tableWidget->setItem(2, 2, new QTableWidgetItem(QString("88")));