[PyQt] QComboBox behaviour with PyQt4/PyKDE4

Christoph Burgmer chrislb at gmx.de
Tue Apr 8 23:16:56 BST 2008

Hi list,

I started today with PyQt4/PyKDE4 and am experiencing some issues. I read 
about menus not being shown with the Oxygen theme, so I'll only point out the 
second problem I have.

Using one of the simple examples delivered with PyKDE4 I am trying to fill a 
QComboBox with content. It is not possible to me though, to get the list to 
drop down when trying to open it.

Beneath I add a simple model having two rows of data. I print out the count of 
rows later to verify that it took the input. Data is only shown in the 
unexpanded ComboBox if .setEditable(True) is called.

> class MainWindow (KXmlGuiWindow):
>     def __init__ (self):
>         KXmlGuiWindow.__init__ (self)
>         self.comboBox = QtGui.QComboBox()
>         self.comboBox.setModelColumn(1)
>         self.comboBox.setObjectName("comboBox")
>         self.encodingNames = {'a': 'b', '1': '2'}
>         model = QtGui.QStandardItemModel(len(self.encodingNames), 2);
>         for row, name in enumerate(self.encodingNames):
>             model.setItem(row, 0,
> QtGui.QStandardItem(QtCore.QString(str(row))))
> 		model.setItem(row, 1,
> QtGui.QStandardItem(QtCore.QString(name)))
>	   self.comboBox.setModel(model) 
>         self.setCentralWidget(self.comboBox);
>         self.setupGUI()
>         print self.comboBox.count()
>         self.comboBox.setEditable(True)

Can somebody reproduce this problem?


More information about the PyQt mailing list