PDA

View Full Version : Implementing comboBox in TableView withOUT QSqlRelationalTableModel



scarleton
31st October 2010, 22:55
I have an almost classically QSqlRelationalTableModel situation:

The parent table is OrderItem, which contains a PictureId. The PictureId is a foreign key to the Picture table. In the QTableView of OrderItems, the user should be able to select the picture for a combo box.

Here is the almost part: The collection of pictures is only a subset of all the images. Something along the lines of:

SELECT * FROM Picture WHERE sessionId = ?

From everything I can tell, the QSqlRelation does NOT support conditions on the child (Picture) table. So I am assuming I will need to create another QSqlTableModel for Picture and wire that into the QTableView manually. Where might I find a good example of how to do this?

Sam