Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlRelationalTableModel and Delegates when implementin a Many-to-many (data model)
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 808 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gtpt
    wrote on last edited by
    #1

    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()
    {
    view->setFocus();
    QModelIndex index = view->currentIndex();
    if(!index.isValid())
    {
    qDebug() << "Error ...";
    return;
    }
    model->removeRow(view->currentIndex().row());
    model->select();
    }
    @

    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.
    Thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gtpt
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved