Jens over at the qt-project forums answered this question, so I'll link to it here.
In short, there is a design flaw in the spin box drawing (at least in QGtkStyle) whereby it only uses the size of the option.rect
, ignoring it's position. Although this perfectly reasonable in a 'normal' painting scenario because it maps to the widget origin, it fails when rendered in an item view due to the cell offset.
To solve this, move option.rect
to the widget origin (i.e. move it's top left corner to (0,0)), and then translate the QPainter
to take into account the cell offset.