Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSqlTableModel - setting default values using the primeInsert signal.



  • In my model I have a primeInsert() signal handler that sets a default value:

    void MySqlTable::onPrimeInserted(int row, QSqlRecord &r) {
    r.setValue(numberCol, row + 1);
    }

    If the model is later submitted(), the modified value is not saved.
    However, I found that if I call setGenerated(), the value does indeed get saved.

    void MySqlTable::onPrimeInserted(int row, QSqlRecord &r) {
    r.setValue(numberCol, row + 1);
    r.setGenerated(numberCol, true);
    }

    Is this the intended behavior for how setting values using primeInsert is supposed to work? Doesn't seem right somehow.
    Regards,
    Mike


Log in to reply