fix: #3 当某行数据小于最小列数时加载报错

This commit is contained in:
阿甘 2023-08-08 21:52:23 +08:00
parent 7e7a3e2ab3
commit f55de36c25

View File

@ -126,6 +126,12 @@ void MainWindow::loadTextFile(const QString& fileName)
tableWidget->setHorizontalHeaderLabels(row);
}
// 补充空白内容,确保行的列数与表格的列数一致
while (row.count() < tableCol)
{
row.append(""); // 添加空白内容
}
for (int j = 0; j < tableCol; ++j)
{
QTableWidgetItem* item = new QTableWidgetItem(row.at(j));