Hi Wysota!
finally i am able now to input a new rec
I hope you mean like that:
void MainWindow::insertNewRow()
{
QString table
= ui.
tabellen_cb->currentText
();
model->setTable(table);
model->select();
ui.tableView->setModel(model);
ui.tableView->show();
//Just insert an empty row into your model using insertRow() or insertRecord()
//with an empty record
model->insertRecord(-1, rec);
//and order the view to go into edit mode on the newly inserted row.
}
void MainWindow::insertNewRow()
{
QString table = ui.tabellen_cb->currentText();
QSqlTableModel *model = new QSqlTableModel;
model->setTable(table);
model->setEditStrategy(QSqlTableModel::OnFieldChange);
model->select();
ui.tableView->setModel(model);
ui.tableView->show();
//Just insert an empty row into your model using insertRow() or insertRecord()
//with an empty record
QSqlRecord rec = model->record();
model->insertRecord(-1, rec);
//and order the view to go into edit mode on the newly inserted row.
model->setEditStrategy(QSqlTableModel::OnRowChange);
}
To copy to clipboard, switch view to plain text mode
Bookmarks