adamkoczur
12th February 2009, 14:45
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
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