Hi I am using a QTableView to display data from a sql table using the qsqltablemodel asfollows:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
model = new QSqlTableModel(this);
model->setTable("staging");
model->select();
model->setHeaderData(0, Qt::Vertical, tr("ID"));
model->setHeaderData(1, Qt::Vertical, tr("Region"));
model->setHeaderData(2, Qt::Vertical, tr("T1"));
model->setHeaderData(3, Qt::Vertical, tr("N1"));
model->setHeaderData(4, Qt::Vertical, tr("M1"));
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableView->setModel(model);
ui->tableView->showRow(1);
ui->tableView->resizeColumnsToContents();
}
I just want to display the table in such a view that columns are presented as rows and rows as columns. I have searched google etc.. but cannot find any simple solution. There is mention of a proxy model but I am unsure how i can implement that with a QSqltablemodel which does not use a data method in this example, rather a model->select() statement which populate the whole model at once. Any guidance will be appreciated.
Usage: