fix: #3 当某行数据小于最小列数时加载报错
This commit is contained in:
parent
7e7a3e2ab3
commit
f55de36c25
|
@ -126,6 +126,12 @@ void MainWindow::loadTextFile(const QString& fileName)
|
||||||
tableWidget->setHorizontalHeaderLabels(row);
|
tableWidget->setHorizontalHeaderLabels(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 补充空白内容,确保行的列数与表格的列数一致
|
||||||
|
while (row.count() < tableCol)
|
||||||
|
{
|
||||||
|
row.append(""); // 添加空白内容
|
||||||
|
}
|
||||||
|
|
||||||
for (int j = 0; j < tableCol; ++j)
|
for (int j = 0; j < tableCol; ++j)
|
||||||
{
|
{
|
||||||
QTableWidgetItem* item = new QTableWidgetItem(row.at(j));
|
QTableWidgetItem* item = new QTableWidgetItem(row.at(j));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user