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. [SOLVED] How can I access foreign keys/records in QSqlRelationalTableModel/QItemDelegate
QtWS25 Last Chance

[SOLVED] How can I access foreign keys/records in QSqlRelationalTableModel/QItemDelegate

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 637 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.
  • J Offline
    J Offline
    JosephMorgan
    wrote on last edited by
    #1

    I am using QSqlRelationalTableModel::setRelation to display data from a foreign table in a tableview. The delegate examples explain how to change which foreign record is displayed (using combo boxes) but not how to change the actual foreign record itself. I have a custom delegate setup and can createEditor and setEditorData but I cannot figure how to setData since in my delegate, I only seem to have access to the displayable data and have no access to the foreign record for editing purposes. If I could access the foreign key in my delegate, I could move forward. Does anyone know how to do this? Or is there a better way?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JosephMorgan
      wrote on last edited by
      #2

      I figured out a solution. Create another QSqlRelationalTableModel without relations set and use it to grab the foreign record for editing purposes.

      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