QT总是越界,我想在tablewidget中输出txt文件,QT越界报错,后来网上找了个没问题的代码,新建个项目,运行还是报错
```c++
ui->tableWidget->setColumnCount(6);
QStringList header;
header<<"书名"<<"作者"<<"出版日期"<<"总数量"<<"单价"<<"在馆数量";
ui->tableWidget->setHorizontalHeaderLabels(header);
QFile f("E:\\librarQTUI\\bookdata.txt");
f.open(QIODevice::ReadOnly|QIODevice::Text);
QTextStream output(&f);
QHash<QString,QString> varHash;
QString lineStr;
QStringList linelist;
varHash.clear();
linelist.clear();
while(!output.atEnd())
{
lineStr=output.readLine();
linelist=lineStr.split("\t");
int rowCount=ui->tableWidget->rowCount();
ui->tableWidget->insertRow(rowCount);
for(int i=0;i<6;i++)
{
ui->tableWidget->setItem(rowCount,i,new QTableWidgetItem(linelist[i]));
}
}
f.close();
}
```