[Qt-interest] QComboBox and QSortFilterProxyModel

David Heremans david.heremans at intersoft-electronics.com
Thu May 26 13:53:29 CEST 2011


Hello,

I have a custom datamodel (derived from QAbstractTableModel) with a few
columns representing a guid, type, description,...

I want the user to select items based on a description but filtered out
by type, so I instantiated a QSortFilterProxyModule and hooked this one
up to a QComboBox.

It seems that from the combobox I can get the numerical index or the
QString that is displayed by the combobox, but is there a way to
retrieve the QModelIndex of the selected item ?
Or do I really need to iterate over my data using a 'QVariant data(const
QModelIndex &index, int role) const;' method to compare the the values
one by one?

rgds

David H




More information about the Qt-interest-old mailing list