C++ 读取多个QTableWidget项';
我试图读入表中的所有行并将其存储到QVariant列表中,但每次运行该程序时,它都会崩溃。我知道它存储数据是因为qDebug(),但是在它完成循环后,程序崩溃了。我的代码如下C++ 读取多个QTableWidget项';,c++,qt,qtablewidget,C++,Qt,Qtablewidget,我试图读入表中的所有行并将其存储到QVariant列表中,但每次运行该程序时,它都会崩溃。我知道它存储数据是因为qDebug(),但是在它完成循环后,程序崩溃了。我的代码如下 int RowNumber = ui->tableWidget_Invoice->rowCount(); for(int y = 0; y<=RowNumber; y++) { Qty << ui->tableWidget_Invoice->
int RowNumber = ui->tableWidget_Invoice->rowCount();
for(int y = 0; y<=RowNumber; y++)
{
Qty << ui->tableWidget_Invoice->item(y, 0)->text();
Description << ui->tableWidget_Invoice->item(y, 1)->text();
Product_CODE << ui->tableWidget_Invoice->item(y, 2)->text();
Unit_Price << ui->tableWidget_Invoice->item(y, 3)->text();
Total_Price << ui->tableWidget_Invoice->item(y, 4)->text();
}
int RowNumber=ui->tableWidget\u Invoice->rowCount();
对于(int y=0;yitem(y,0)->text();
说明表Widget_发票->项目(y,1)->文本();
产品代码表格小部件发票->项目(y,2)->文本();
单价表小部件发票->项目(y,3)->文本();
总价表小部件发票->项目(y,4)->文本();
}
y
-如果计数为5,最后一项有索引4-如何?它最初是肯定的,它是否与一起工作“但在完成循环后程序崩溃”-好的,它必须工作