QT使用tablewidget控件
ui->tableWidget->setColumnCount(5); ui->tableWidget->setHorizontalHeaderLabels(QStringList() << "name" << "url" << "password" ); ui->tableWidget->setRowCount(5); QStringList nameList; nameList << "123" << "456" << "789"; for (int i =0; i < 3; i++) { int col = 0; ui->tableWidget->setItem(i,col++,new QTableWidgetItem(nameList[i])); ui->tableWidget->setItem(i,col++,new QTableWidgetItem(nameList[i])); ui->tableWidget->setItem(i,col++,new QTableWidgetItem(nameList[i])); }