D
D
Denis2013-12-24 13:20:24
Qt
Denis, 2013-12-24 13:20:24

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);
}

But after inserting the row, the cells are still empty.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question