[PyQt] Trouble reading a model index from an "untouched" combo box

Demetrius Cassidy dcassidy36 at mass.rr.com
Tue Jan 26 22:41:40 GMT 2010

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. Try to use self.comboBox.currentIndex() instead 
- it returns -1 if theres no selected index (which there won't be when 
you first set the model until you manually or programatically select one)


Claudio Felix wrote:
> 2010/1/26 Demetrius Cassidy <dcassidy36 at mass.rr.com>:
>> How about selecting index 0 once the combobox is initialized with the
>> database data? It sounds to me that it has no valid index when first
>> initialized, and if you try to programmatically select the first index, it's
>> returning an invalid one. You don't need to generate a signal, just use
>> something like .setCurrentIndex(0).
> Thanks for the answer Demetrius. Unfortunately, it didn't change it.
> Maybe I do have to use a QDataWidgetMapper on the combo box? I thought
> just getting the model associated with it should do it.. it shows all
> the models' values indeed...
> Cheers...
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

More information about the PyQt mailing list