QSqlRelationalTableModel and Delegates when implementin a Many-to-many (data model)

  • Hello!

    I'm having some problems understanding how to implement a Many-to-many relation using Qt and MySql, and this is why i'm building this small example ( "here ":https://app.box.com/s/d4pvg4e876x47tstspxc).
    In theory, i will need to create a cross-reference table ( "wikipedia ...":http://en.wikipedia.org/wiki/Many-to-many_(data_model) ).
    This is my database model:
    !https://dl.dropboxusercontent.com/u/2715374/qtcentre/EERDiagram.png(EER Diagram)!
    All working fine with tables A and B.
    When it comes to the dialog that manages the "AB" table, things are not looking good .

    *Problem 1: *
    When i updade data in tables A or B, after updating the model in the AB Dialog, the delegates still show the old info in the AB Dialog. Is there a way to update this without closing and reopening the dialog?

    Problem 2:
    Deleting a record fails with this code:
    void abDialog::on_delButton_clicked()
    QModelIndex index = view->currentIndex();
    qDebug() << "Error ...";

    Problem 3
    Insert works in the end, after updating the model, but the editing fase still very messy.
    There are other issues here but, for the moment, i just want to know if i'm missing something really obvious regarding the use o QSqlRelationalModel and delegates!
    Any help appreciated.

  • Does anyone know an example, similar to this, so that i can take a look?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.