Results 1 to 7 of 7

Thread: Method to read foreign key values from QSqlRelationalTableModel ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jun 2011
    Location
    Białystok, Poland
    Posts
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Re: Method to read foreign key values from QSqlRelationalTableModel ?

    Old thread but I was looking for solution. Here is what You should do:

    model->setRelation(model->fieldIndex("continent_id"), QSqlRelation("Table_2", "continent_id", "continent_name, continent_id as continent_id"));

    or something like that. I have table Orders with contractor_id and Contractors with id so I had to use:

    setRelation(this->fieldIndex("contractor_id"), QSqlRelation("Contractors", "id", "name, contractor_id as contractor_id"));

    'displayColumn' in Qt documentation is misleading. It should be called displayColumns.

  2. The following user says thank you to 7ymekk for this useful post:

    Al_ (16th November 2013)

Similar Threads

  1. Replies: 3
    Last Post: 26th February 2010, 23:37
  2. How to read and get the values out of the xml?
    By dark1988 in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2008, 01:29
  3. How to read and get the values out of the xml?
    By dark1988 in forum Qt Programming
    Replies: 6
    Last Post: 15th July 2008, 09:41
  4. FOREIGN KEY + QComboBox
    By eleanor in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2007, 11:37
  5. Replies: 8
    Last Post: 28th May 2007, 21:32

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
  •  
Qt is a trademark of The Qt Company.