#include <QStandardItemModel>
#include <QHeaderView>
private:
#include <QStandardItemModel>
#include <QHeaderView>
private:
QStandardItemModel model;
QModelIndex modelIndex;
QStandardItem *item00;
QStandardItem *item01;
QStandardItem *item02;
QStandardItem *item03;
QStandardItem *item10;
QStandardItem *item11;
QStandardItem *item12;
QStandardItem *item13;
QStringList horizontalHeader;
QStringList verticalHeader;
To copy to clipboard, switch view to plain text mode
void MainWindow::fillTable()
{
horizontalHeader.append("SPH");
horizontalHeader.append("CYL");
horizontalHeader.append("AXIS");
horizontalHeader.append("A.D.D");
verticalHeader.append("R");
verticalHeader.append("L");
model.index(1,1,model.index(0,0));
model.setHorizontalHeaderLabels(horizontalHeader);
model.setVerticalHeaderLabels(verticalHeader);
model.setItem(0, 0, item00);
model.setItem(0, 1, item01);
model.setItem(0, 2, item02);
model.setItem(0, 3, item03);
model.setItem(1, 0, item10);
model.setItem(1, 1, item11);
model.setItem(1, 2, item12);
model.setItem(1, 3, item13);
ui->tableView->setModel(&model);
ui->tableView->resizeRowsToContents();
ui->tableView->resizeColumnsToContents();
}
void MainWindow::fillTable()
{
horizontalHeader.append("SPH");
horizontalHeader.append("CYL");
horizontalHeader.append("AXIS");
horizontalHeader.append("A.D.D");
verticalHeader.append("R");
verticalHeader.append("L");
model.index(1,1,model.index(0,0));
model.setHorizontalHeaderLabels(horizontalHeader);
model.setVerticalHeaderLabels(verticalHeader);
item00 = new QStandardItem(QString("0"));
model.setItem(0, 0, item00);
item01 = new QStandardItem(QString("0"));
model.setItem(0, 1, item01);
item02 = new QStandardItem(QString("0"));
model.setItem(0, 2, item02);
item03 = new QStandardItem(QString("0"));
model.setItem(0, 3, item03);
item10 = new QStandardItem(QString("0"));
model.setItem(1, 0, item10);
item11 = new QStandardItem(QString("0"));
model.setItem(1, 1, item11);
item12 = new QStandardItem(QString("0"));
model.setItem(1, 2, item12);
item13 = new QStandardItem(QString("0"));
model.setItem(1, 3, item13);
ui->tableView->setModel(&model);
ui->tableView->resizeRowsToContents();
ui->tableView->resizeColumnsToContents();
}
To copy to clipboard, switch view to plain text mode
Bookmarks