[Qt-interest] QComboBox and QSortFilterProxyModel

Anton Chernov mechernov at gmail.com
Thu May 26 14:13:44 CEST 2011


http://doc.qt.nokia.com/4.7/qcombobox.html#model

gives the abstract model and you can query the model index with

http://doc.qt.nokia.com/4.7/qabstractitemmodel.html#index

with column 0 from that model.

2011/5/26 David Heremans <david.heremans at intersoft-electronics.com>

> 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
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110526/2f684860/attachment.html 


More information about the Qt-interest-old mailing list