I'm currently implementing a custom delegate, in part of which I need a QSpinBox
to be drawn in the paint(..)
method.
void Sy_floatingPointPD::paint( QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index ) const
{
painter->save();
// Paint check box.
QStyleOptionSpinBox spOpt;
spOpt.palette = option.palette;
spOpt.rect = option.rect;
spOpt.state = option.state;
spOpt.frame = true;
spOpt.stepEnabled = QAbstractSpinBox::StepUpEnabled |
QAbstractSpinBox::StepDownEnabled;
style->drawComplexControl( QStyle::CC_SpinBox, &spOpt, painter );
painter->restore();
}
Unfortunately it appears as:
As you can see the step buttons are drawn massive and only the down arrow appears. Interestingly the width of the buttons mirrors that of the first table column, despite option.rect
being the size of the cell (which is correct, which is presumably why the frame is drawn correctly).
Any ideas what information I'm not giving QStyle
?