constructor
{
..
sqlModel->setHeaderData(0,Qt::Horizontal,"Topic");
sqlModel->setHeaderData(1,Qt::Horizontal,"Date");
sqlModel->setHeaderData(2,Qt::Horizontal,"Data");
sqlModel->insertColumns(column,3);
..
}
void NoteBook::addRecord()
{
sqlModel->insertRows(row,1);
sqlModel
->setData
(sqlModel
->index
(row,
0),
QVariant(topicValue
));
sqlModel
->setData
(sqlModel
->index
(row,
1),
QVariant(dateValue
));
sqlModel
->setData
(sqlModel
->index
(row,
2),
QVariant(dataValue
));
tableView->setModel(sqlModel);
sqlModel->submitAll();
++row;
tableView->show();
}
constructor
{
..
sqlModel->setHeaderData(0,Qt::Horizontal,"Topic");
sqlModel->setHeaderData(1,Qt::Horizontal,"Date");
sqlModel->setHeaderData(2,Qt::Horizontal,"Data");
sqlModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
sqlModel->insertColumns(column,3);
..
}
void NoteBook::addRecord()
{
sqlModel->insertRows(row,1);
sqlModel->setData(sqlModel->index(row,0),QVariant(topicValue));
sqlModel->setData(sqlModel->index(row,1),QVariant(dateValue));
sqlModel->setData(sqlModel->index(row,2),QVariant(dataValue));
tableView->setModel(sqlModel);
sqlModel->submitAll();
++row;
tableView->show();
}
To copy to clipboard, switch view to plain text mode
Bookmarks