[PyQt] QStyledItemDelegate option properties?

Eric Thomson thomson.eric at gmail.com
Mon Dec 7 04:06:55 GMT 2015

In Qt 4.8.6/PyQt 4.10.4, I am reimplementing the `paint` method in a
`QStyledItemDelegate`, just to help myself understand the default
mechanics of tree views.

The second input to the `paint` method is `option`, a
`QStyleOptionViewItem`, which is supposed to be an instance of


Such objects are supposed to contain information about the three main
subelements of an item in a view: the text, icon, and checkstate.
However, whenever I try to access the text (using option.text) I
always get an empty string. That is, option seems to be incomplete.
When I print option.version, it returns 4, so the typing seems right.
Am I misreading what option.text is supposed to be? The index has the
data, so I typically just pull it from there when I reimplement paint,
but I'm wondering what is going on under the hood.

More information about the PyQt mailing list