Answer the question
In order to leave comments, you need to log in
QSqlTableModel and dependencies between tables
There is a form with two tables, when adding a row to one of them, one field must be substituted from the second.
Tables have a QSqlTableModel model.
Tried like this:
void window::on_button_add_bottom_clicked()
{
QModelIndex index = ui->top_list->selectionModel()->selectedIndexes()[0];
QVariant id = index.sibling(index.row(), 0).data();
QSqlRecord row;
row.setValue(0, id);
bottom_model->insertRecord(0, row);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question