我有这个代码,其中Almacenador是一个由此构成的QStringList:
("250", "100", "9500", "400", "180", "100", "8400", "400", "110", "200", "10000", "400", "110", "230", "9000", "400");
int filas = Almacenador.size()/Properties;
int columnas = Properties;
qDebug() << filas;
qDebug() << columnas;
ui->Workspace->setRowCount(filas);
ui->Workspace->setColumnCount(columnas);
int h = 0;
for( int r = 0 ; r < ui->Workspace->rowCount(); ++r )
{
for( int c = 0; c < ui->Workspace->columnCount(); ++c )
{
QString value = Almacenador[h];
h++;
qDebug() << r << c << value;
ui->Workspace->setItem(r, c, new QTableWidgetItem(value));
ui->Workspace->setItem(r,c,new QTableWidgetItem (value));
}
}
我在ui->Workspace-SetItem(r,c,new QTableWidgetItem(value));
中收到错误。但如果我更改了值,即QString value = "Empty";
QTableWidget变满了。