hi there,
I have 2 tables here.
Qt Code:
  1. Table 1 : ID, typeID, name, other feilds...
  2. Table 2 : typeID, typeName
To copy to clipboard, switch view to plain text mode 

Now, I have a QTableView which show the contents of typeID, name,
and another QWidget which display the detail information. It's very same with the Qt Demo Program Books .

I use QSqlRelationalTableModel as the model. and create the relation between Table 1 and 2.
Qt Code:
  1. // Set the relations to the other database tables
  2. m_model->setRelation( mTypeIdx, QSqlRelation( "types", "id", "name" ) );
To copy to clipboard, switch view to plain text mode 

You know after I did this, QTableView would not disaplay the typeID, It replaced by typename.
How can I display the typeID rather the typename in QTableView ?
I digged the whole forum, without any tips.

Thanks.