Hello everybody
QT:4.1.1
I am able with this code to insert a Row in my table:
QString table
= ui.
tabelle_le->text
();
model->setTable(table);
model->select();
ui.tableView->setModel(model);
ui.tableView->show();
rec.setValue("status", "test");
model->insertRecord(-1, rec);
QString table = ui.tabelle_le->text();
QSqlTableModel *model = new QSqlTableModel;
model->setTable(table);
model->setEditStrategy(QSqlTableModel::OnFieldChange);
model->select();
QSqlRecord rec = model->record();
ui.tableView->setModel(model);
ui.tableView->show();
rec.setValue("status", "test");
model->insertRecord(-1, rec);
To copy to clipboard, switch view to plain text mode
My problem is, that i have some tables, so i am searching a solution how to implement my function so that i have not to write every columns like:
table1
rec.setValue("status", "test");
rec.setValue("date", "test");
rec.setValue("price", "test");
.
.
.
rec.setValue("status", "test");
rec.setValue("date", "test");
rec.setValue("price", "test");
.
.
.
To copy to clipboard, switch view to plain text mode
table2
rec.setValue("address", "test");
rec.setValue("tel", "test");
rec.setValue("mobil", "test");
.
.
.
rec.setValue("address", "test");
rec.setValue("tel", "test");
rec.setValue("mobil", "test");
.
.
.
To copy to clipboard, switch view to plain text mode
I would like to insert a empty row: modal->insertRecord(-1, rec); fill cells and save it
Can somebody see the problem? Have somebody a idea how to implement this dynamic?
Bookmarks