PDA

View Full Version : Get data from a QSqlRelationTableModel



aguleo
27th May 2014, 22:00
Hello,
I have the table Items(id, idColor, other, ...)
To access this table i have :

model - QSqlRelationTableModel
view - QTableView


To get data from the current index i use:


qDebug() << model->data(indexField).toString();


This works fine, except for the field that are foreign keys (idColor), and that i used a QSqlRelationalDelegate. In this cases, instead of the id e get the related data (the color as a string), in the other table.
How can i get the data form the table (the id) and not the related data?

Thanks

wysota
27th May 2014, 23:18
Did you try using Qt::EditRole?

aguleo
29th May 2014, 15:40
Just tried all display roles: 0,1,2,3,4,5,13.
None gives the result i want.