[PyQt] Override QStyledItemDelegate.initStyleOption not working?

Andreas Pakulat apaku at gmx.de
Mon Jan 9 23:11:49 GMT 2012


Hi,

I'd like to customize the display of a model via a styleditemdelegate,
in particular I want to add a decorating icon depending on some custom
role from the model.

As far as I can see the easiest way to do this would be overriding
initStyleOption since then I can set the icon and icon-size directly on
the option and leave the rest to the standard paint etc. methods.

Unfortunately it seems this does not work in PyQt, the code is executed
properly but the icon does not show up in the itemview. Since the
function in C++ takes a pointer to the option-parameter I wonder wether
this is simply not possible with PyQt or wether I need to go hunting for
the bug elsewhere?

Using Qt 4.7.4, sip 4.13  and PyQt 4.8.6

Andreas



More information about the PyQt mailing list