It’s compiling OK, just not working…
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
CreateModel();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::CreateModel(void)
{
QSqlTableModel *model = new QSqlTableModel(this);
model->setTable("Text");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
model->setHeaderData(0, Qt::Horizontal, tr("A"));
model->setHeaderData(1, Qt::Horizontal, tr("B"));
model->setHeaderData(2, Qt::Horizontal, tr("C"));
model->setHeaderData(3, Qt::Horizontal, tr("D"));
model->setHeaderData(4, Qt::Horizontal, tr("E"));
model->insertRows(0,0);
ui->tableView->setModel(model);
ui->tableView->hideColumn(0); // don't show the ID
ui->tableView->show();
};
I have all the correct includes in the .pro file etc. And I have followed the instructions carefully.
Could anyone please help me?