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

2010-01-30 Thread Claudio Felix
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

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

2010-01-30 Thread Andreas Pakulat
On 30.01.10 22:44:24, Claudio Felix wrote: 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

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

2010-01-27 Thread Demetrius Cassidy
Just took a peak at QAbstractItemView class and your right it's fully implemented. The view is asking the selectionModel what the current selected index is, and if it has no selection model (not sure if that's even possible) it returns an invalid QModelIndex. QComboBox.currentIndex is just

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

2010-01-27 Thread Claudio Felix
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

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

2010-01-27 Thread Andreas Pakulat
On 27.01.10 09:08:13, Claudio Felix wrote: 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

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

2010-01-27 Thread Claudio Felix
Well, the combobox has initially no selected/current entry - AFAIK. Only once you select one it'll be set. Hence the invalid index. However a setCurrentIndex with a value != 0 on the combobox should change that already I think. Another thing in your case is that box.view().currentIndex()

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

2010-01-27 Thread Andreas Pakulat
On 27.01.10 17:33:18, Claudio Felix wrote: Well, the combobox has initially no selected/current entry - AFAIK. Only once you select one it'll be set. Hence the invalid index. However a setCurrentIndex with a value != 0 on the combobox should change that already I think. Another thing

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

2010-01-26 Thread Claudio Felix
Hi everyone, I'm developing an app which loads data from a database table into a QSqlTableModel. At some point I associate this model to a Combo Box (using QComboBox.setModel). The strange thing is, when I try to read the current model index from the combo box view, for getting the selected

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

2010-01-26 Thread Claudio Felix
Hi everyone, I'm developing an app which loads data from a database table into a QSqlTableModel. At some point I associate this model to a Combo Box (using QComboBox.setModel). The strange thing is, when I try to read the current model index from the combo box view, for getting the selected

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

2010-01-26 Thread Demetrius Cassidy
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

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

2010-01-26 Thread Claudio Felix
2010/1/26 Demetrius Cassidy dcassid...@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.

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

2010-01-26 Thread Demetrius Cassidy
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

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

2010-01-26 Thread Andreas Pakulat
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