Results 1 to 1 of 1

Thread: QSqlRelationalTableModel - two references to the same table

  1. #1
    Join Date
    Feb 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QSqlRelationalTableModel - two references to the same table

    Hi,

    Is it possible to set relations to more than one field in an other table using one foreign key?

    Having two tables: x (id, y_id fk y(id), ...), y (id, a, b)
    and X class which is a subclass of QSqlRelationalTableModel I do:

    setTable("x");
    setRelation(fieldIndex("y_id"), QSqlRelation("y", "id", "a"));

    Now, if I try:
    setRelation(fieldIndex("y_id"), QSqlRelation("y", "id", "b"));
    the first relation will be lost... And I need to put both fields - a and b from table y to my view.

    Is it possible at all or should I subclass QSqlQueryModel, instead and implement my own setData etc?

    Thanks in advance for any help.
    Adam
    Last edited by adamkoczur; 12th February 2009 at 18:20. Reason: spelling error

Similar Threads

  1. Postgresql QSqlRelationalTableModel empty table
    By RolandHughes in forum Qt Programming
    Replies: 0
    Last Post: 12th November 2008, 17:18
  2. Replies: 3
    Last Post: 5th October 2008, 23:41
  3. how to add sub table to QSqlRelationalTableModel
    By SunnySan in forum Qt Programming
    Replies: 1
    Last Post: 30th July 2008, 11:05
  4. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 22:12
  5. creating table plugin
    By mgurbuz in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 13: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.