PDA

View Full Version : custom display in a QComboBox



scarleton
2nd September 2010, 23:34
A model SessionListSqlModel, which derives from QSqlTableModel, is set as the model to a QComboBox control. What should be displayed is a compound string from multiple columns. What is the correct way to do this?

My first thought is to set QComboBox's modelColumn to one value higher then there are columns. The in the model override the data function and build the compound string for the new column.

But is there some way I could do the same type of thing with a QItemDelegate? I would prefer to use a QItemDelegate because later I might end up using this model else where and I would really prefer not to have something that is specific to this combo box in the model.

Sam

Lykurg
3rd September 2010, 07:39
? Whats about QComboBox::setItemDelegate()?

EDIT: If you don't know how to access other column in the delegates paint method: QModelIndex::sibling(),

scarleton
3rd September 2010, 22:13
Do you know if there is an example of what I am trying to do somewhere in the world?