Results 1 to 2 of 2

Thread: Can I obtain original foreign key value (or table row) from QSqlRelationalTableModel?

  1. #1
    Join Date
    Feb 2010
    Posts
    17
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Can I obtain original foreign key value (or table row) from QSqlRelationalTableModel?

    Hi,

    I'm using QSqlRelationalTableModel but unfortunately, it removes the foreign key fields and replaces them with the displayColumn value from the related model.

    Example:

    Table "Foo" has a column called bar_id which references table "Bar". Foo is represented by a QSqlRelationTableModel and has the Bar table set as a relation. Any records fetched from the Foo relational model will no longer have a column/field named "bar_id". Instead, the column name will resemble the display column name, set when attaching the relation.



    My question is: How can I get the rest of the data from Bar? I can't do a filter+select on the Bar table, because I don't have access to bar_id anymore. Is there some way of obtaining the original foreign key, or can I get the related row from the Bar table in another way?

    Any help would be greatly appreciated.

    Thanks

  2. #2
    Join Date
    Dec 2009
    Posts
    47
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Can I obtain original foreign key value (or table row) from QSqlRelationalTableMo

    see http://www.qtcentre.org/threads/2860...onalTableModel for similar question and possible workaround.

Similar Threads

  1. Replies: 6
    Last Post: 12th October 2015, 09:59
  2. Replies: 1
    Last Post: 3rd April 2010, 16:47
  3. How to get the index of original SQL table?
    By Kode.Cooper in forum Qt Programming
    Replies: 0
    Last Post: 27th January 2010, 09:43
  4. Replies: 5
    Last Post: 8th October 2008, 21:01
  5. How to get list of database's table's foreign keys?
    By jambrek in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2008, 06:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.