hi there,
I have 2 tables here.
Table 1 : ID, typeID, name, other feilds...
Table 2 : typeID, typeName
Table 1 : ID, typeID, name, other feilds...
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.
// Set the relations to the other database tables
m_model
->setRelation
( mTypeIdx,
QSqlRelation( "types",
"id",
"name" ) );
// Set the relations to the other database tables
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.
Bookmarks