QSqlRelationalTableModel doesn't work with MySQL views at all...
So, I need two models for this table: one with relations set and other without..
QSqlRelationalTableModel doesn't work with MySQL views at all...
So, I need two models for this table: one with relations set and other without..
Naaa... it's not that bad. You can always use QSqlQueryModel::record() which will return the real record, with the foreign key instead of resolved relation.
QSqlRelationalTableModel overrides completely all foreign keys with their values and i get record with values already resolved... Qt coding is not so fun in this place...
So use the relation model and check the index yourself. What do you need it for anyway? What's the point in hiding foreign keys if you want to access them later on?
Hmm... You ask Qt for a car and you are complaining it gave you a car instead of a bicycle?Qt coding is not so fun in this place...
QSqlRelationalTableModel is very helpful when i want to show one table, but if i want to fill the dialog with additional info about some of fereign keys (e. g. mesure unit and producer of requested product from one of requests), i need non-resolved index, other words, i need functionality of both car and bicycle.What do you need it for anyway? What's the point in hiding foreign keys if you want to access them later on?
Hmm... You ask Qt for a car and you are complaining it gave you a car instead of a bicycle?
Or don't i just know what i realy need?![]()
I don't understand what you mean by "additional info about some of foreign keys". A key is a key (number), nothing more. If you want more information retrieved from the other table either use a view (in terms of the database, not model-view), use QSqlQueryModel, use a proxy model or use the base implementation of data - explicitely call QSqlTableModel::data instead of QSqlRelationalTableModel::data.
Bookmarks