[PyQt] QComboBox inside the QTreeWidgetItem?

Piotr Byzia piotr.byzia at gmail.com
Wed Nov 4 08:24:24 GMT 2009


Hi,

This is my first post to the list, so hello everyone!

I recently started developing a small PyQT4 application with VTK 3D  
visualization, and I encountered a few problems, first one is  
described in this email.

I wanted to include a combo box inside my QTreeWidgetItem, but it does  
no appear on the screen:

self.tree_item = QTreeWidgetItem(self.widget_layers, [QString 
(structure_name), QString(str(sequence_length))])

combo = QComboBox()
combo.addItem(QString('1st item'), Qt.DisplayRole)
self.widget_layers.setItemWidget(self.tree_item, 4, combo)
print type(self.widget_layers), type(self.tree_item), type(combo)

print returns following values:
<class 'PyQt4.QtGui.QtreeWidget'> <class  
'PyQt4.GtGui.QTreeWidgetItem'> <class 'PyQt4.QtGui.QComboBox'>

What am I doing wrong?
I found similar listing in the archive:
http://www.riverbankcomputing.com/pipermail/pyqt/2009-August/024067.html
but author seems to have no problem with the QPushButton, which does  
not appear in my app, so I assume that there is some other problem  
than defining combo box like above?

And once it's working, how can I connect to its activated SIGNAL?

More general question would be: how can I get a reference to the given  
item in the QTreeWidgetItem? There is text() but it's now always the  
case...

Thanks,
Piotr Byzia


More information about the PyQt mailing list