[PyQt] A simple way to add another column to QComboBox?

David Boddie david at boddie.org.uk
Fri Sep 4 23:12:06 BST 2009

On Fri Sep 4 22:52:39 BST 2009, Adam W. wrote:

> I have also tried replacing the listview with a tableview, and have
> not like the results too much.  For instance, I could never figure out
> how to hide the headers.  In your example code the
> "view.header().hide()" function returns AttributeError: 'QTableView'
> object has no attribute 'header' and similarly with
> view.setRootIsDecorated(False), I get: AttributeError: 'QTableView'
> object has no attribute 'setRootIsDecorated'.

It's a bit different for QTableView because it has horizontal and
vertical headers. You need to call


and remove the setRootIsDecorated() call. You might also want to add


to remove the grid lines.

[Putting widgets in lists]

> With this approach I've run into many
> problems, like not having a good way to access the QWidget buried deep
> inside the combo box, I was using a mile long,
> combobox.children()[1].children()[1].children()[0]....... thing to
> retrieve and install a event filter too. And I was unable to get the
> move() event to fire, because the QWidget was always at (0,0)...

It sounds like more trouble that it's worth. :-/

> I will look into the delegate approach next, I have yet to work with
> any delegates, so I don't know what kind of info they get passed.  Any
> pointers on this front would be appreciated :)

Although there should be at least one example supplied with PyQt that shows
how to create delegates (itemviews/pixelator), other people reading this
might be able to suggest more useful examples to look at.


More information about the PyQt mailing list