I have a data set, in the form of a matrix… column names are people names, row names are certain attributes… each cell could be a list of 3 radio buttons OR a dropdown box. So i was thinking of using a TableWidget for all of this.
column names are read from file, row names are passed from another function.
should i use TableWidgetItem to add the cells and information? or use the StandardItemModel to add cells and information?
and can somebody show me some sample code in adding such information??
thanks a bunch!
I have this so far but i dont know why it doesnt work
i've tried to add tableWidgetItem in the loop, but nothing comes out, i've tried to add header with modelItem, nothing comes out.....
QFile file("../engD.txt");
if (!file.exists())
{
QMessageBox error;
error.setText("error");
error.exec();
}
if (!file.open(QFile::ReadOnly|QFile::Text))
{
qDebug();
}
QTextStream stream(&file);
QString mText;
while (!stream.atEnd())
{
for (int row =0; row<4; row++)
{
for (int col =0; col<4;col++)
{
mText= stream.readLine();
QTableWidgetItem *newItem = new QTableWidgetItem;
newItem->setText(mText);
ui->tableWidget->setItem(row, col, newItem);
}
}
}
QStandardItemModel *model = new QStandardItemModel(4,4);
model->setHeaderData(0,Qt::Horizontal,mText);
ui->tableWidget->setModel(model);
file.close();