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. QSqlRelationalDelegate and QSqlRelationalTableModel::setRelation Bug ?

QSqlRelationalDelegate and QSqlRelationalTableModel::setRelation Bug ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 994 Views
  • 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.
  • A Offline
    A Offline
    Andy314
    wrote on 14 Sept 2015, 18:06 last edited by Andy314
    #1

    I have the tblCountry and the tblPort. Every port is on one country connected by IDCountry.
    Now I want show and edit the country of every port in a tableview.

      Ports.setTable("tblPort");
        Ports.setRelation(3, QSqlRelation(tblCountry, fieldID, fieldDesc));
        ui->PortsTV->setModel(&Ports);
        ui->PortsTV->setItemDelegateForColumn(3,
            new QSqlRelationalDelegate(ui->PortsTV));
    

    The setRelation works. I see instead of the foreign key the country name.
    Editing works too: I get a dropdown-listbox with all countrys. Changing works. Is see the new country-text in the field in form of a dropbox entry
    BUT: when I select an other row the dropbox dissapear (thats correct) and I should see the text configured by setRelation. BUT I see then the primary key.
    So it seem after editing the setRealation has been switched off. Refreshing the grid show again the text and not the primary key.
    I cannot figure out whats wrong.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Andy314
      wrote on 15 Sept 2015, 06:39 last edited by Andy314
      #2

      Bug or Feature ?

      I found out, that the realation works only OnManualSubmit correct
      Ports.setEditStrategy(QSqlTableModel::OnManualSubmit);
      In all other case I see the PrimaryKey after editing.
      Makes this sense ?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 15 Sept 2015, 20:54 last edited by
        #3

        Hi,

        Sounds a bit fishy, especially if it's not written in the documentation

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 1 Reply Last reply 17 Sept 2015, 12:16
        0
        • S SGaist
          15 Sept 2015, 20:54

          Hi,

          Sounds a bit fishy, especially if it's not written in the documentation

          A Offline
          A Offline
          Andy314
          wrote on 17 Sept 2015, 12:16 last edited by
          #4

          @SGaist
          And very tricky is that the setRelation changes the name of the column.
          I stays not by its original name in the database (ForeignKey) but gets some extensions, so that searching column by name does not work anymore.

          1 Reply Last reply
          0

          1/4

          14 Sept 2015, 18:06

          • Login

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