2010/1/27 Andreas Pakulat <ap...@gmx.de>: > On 26.01.10 17:41:40, Demetrius Cassidy wrote: >> I don't think you need to use the view pointer at all - it's >> returning QAbstractItemView *, which I would assume it would need to >> be casted to the proper class in C++. If that's so, by design the >> Abstract class will return an invalid index. > > I don't think so ;) The function currentIndex on the view is not > virtual, so its implemented in the abstract class already properly. > > And to get a model index to index into the model its easier to ask the > view for it, rather than constructing it yourself with model->index( > combobox->currentIndex(), <model-column>, QModelIndex()) > > Andreas >
Andreas, That was the way I was thinking when I tried the code in the beggining of this thread.. but I'm still stuck retrieving an invalid index if I don't at least click on the combo box (if I do click on it I get a valid index just fine). If you take a look at the code, my intent was to get the ITEM_ID field, which is the table's primary key which corresponds to the item selected on the combo box. Since I have the model for the table already, I found natural to use it for displaying the ITEM_NAME field on the combo box, so I would get the selected item model index from its view to get the ITEM_ID from the table model and use it to optionally filter data on a subsequent SQL Query. I'm intrigued by this QComboBox behavior, for the model was given a "select()" before being associated to it, so I think it should return a valid index. Claudio _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt