From f55de36c2570c2cec2c7fc8c5e62d2f30674da37 Mon Sep 17 00:00:00 2001 From: Crimson Date: Tue, 8 Aug 2023 21:52:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#3=20=E5=BD=93=E6=9F=90=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B0=8F=E4=BA=8E=E6=9C=80=E5=B0=8F=E5=88=97?= =?UTF-8?q?=E6=95=B0=E6=97=B6=E5=8A=A0=E8=BD=BD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mainwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 0e688d7..04c509c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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));