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

David Boddie dboddie at trolltech.com
Fri Sep 4 13:07:06 BST 2009

On Thu Sep 3 22:00:52 BST 2009, Adam W. wrote:

> I have a standard QComboBox displaying about 25 text based items right now,
> left aligned.
> What I want to do is display a bool status for the same items and have it
> right aligned in the child list box (preferably display in the list view
> only too). I haven't determined if the status will be text or an icon yet,
> probably what ever is easier.

There are a few ways to do this. I can think of two just off the top of my

> I've been brainstorming for a while now trying to figure out the best way
> to go about this. I can't seem to extract a list of visible items in the
> combobox's child list with rect's, so I can't draw on top of them.

If you wanted to go that route, you could create your own item delegate and
draw the items yourself.

> I'm still new to Qt, so I don't really have a good grasp of whats possible,
> its likely this is an easy built in feature I haven't found yet. Any
> suggestions would be great.

Probably the easiest place to start is to swap out the view used to display
the combo box's pop-up menu. I've put some sample code up on the PyQt Wiki:


It's also linked to from the SampleCode page:


There are limitations with this approach, but it may be just enough to do
what you want.


More information about the PyQt mailing list