[PyQt] Trouble reading a model index from an "untouched" combo box
felix.claudio at gmail.com
Sun Jan 31 00:44:24 GMT 2010
> Looking at the source code in Qt, I think the reason for this is because
> there's no connection between the currentIndex() in the itemview and the
> one in its selectionModel. In particular the currentChanged() slot in
> the itemview doesn't update its internal currentIndex. I think thats a
> bug in Qt.
> So you'll have to ignore the view here and work with the row from the
> combobox to generate a model index. This should work:
> def getItemID(self:
> idx = self.model.index( self.comboBox.currentIndex(), self.model.fieldIndex("ITEM_ID"), QModelIndex() )
> return self.model.data(idx).toInt()
It worked fine that way. Since these DB records won't change anyway, I
think indexing the ITEM_ID field by the combo box item index will do
the job in the long run for this particular project. About this
potential bug of the lack of connection between the currentIndex in
the itemview and the one in the selectionModel, should we report this
to Phil or maybe open a bug report for QT? I'm not familiar with QT's
source code, but if that is really a bug (and it looks like it is) it
would be nice to get it fixed, huh?
Thank you for your help!
More information about the PyQt