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]));
    }

  

posted on 2021-09-17 13:03  alantop  阅读(326)  评论(0编辑  收藏  举报