Important: Please read the Qt Code of Conduct -

QSql: Wrong column displayed when using OnFieldChange!

  • I have a QSqlDatabase with two tables, a main table with about 1839 records and a category table with three record. The second table has only two columns, id and category.

    @model = new QSqlRelationalTableModel(this, db);
    model->setRelation(1, QSqlRelation("categories", "id", "category"));

    view = new QTableView;
    view->setItemDelegate(new QSqlRelationalDelegate);@

    When I start the program, everything is just fine. But whenever I change the category, instead of the new string the id is displayed until I call model->select() manualy.
    When I use OnManualSubmit, I have to call model->submitAll() before proceeding.

    How can I make sure the value of category is displayed when using OnFieldChange?

Log in to reply