I made my own model as a subclass of QSqlRelationalTableModel and reimplemented QSqlQueryModel::record(int row) like this.

mymodel.h
Qt Code:
  1. class mymodel : public QSqlRelationalTableModel
  2. {
  3. Q_OBJECT
  4. public:
  5. virtual QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const;
  6. virtual QSqlRecord record(int row) const;
  7. };
To copy to clipboard, switch view to plain text mode 

mymodel.cpp
Qt Code:
  1. .
  2. .
  3. .
  4. QSqlRecord mymodel::record(int row) const
  5. {
  6. QSqlRecord rec = QSqlQueryModel::record(row);
  7.  
  8. mod.setTable(tableName());
  9. mod.select();
  10. mod.setFilter(QString("idxxx = %2").arg(rec.value("idxxx").toInt()));
  11.  
  12. return mod.record(0);
  13. }
To copy to clipboard, switch view to plain text mode 

So if I call mymodel::record(int row) i get a QSqlRecord as it is in the database (from QSqlTableModel) without any relation.
I can fetch all entries including foreign keys by using QSqlRecord::value("...").

mannermoe