[Interest] Issue in drawing CheckBox using QStyle::drawPrimitive
Nurmi J-P
jpnurmi at digia.com
Tue Nov 27 15:03:23 CET 2012
> I am drawing a checkbox inside a custom delegate using
> QStyle::drawPrimitive. I use this custom delegate to render items of a
> QListView. Paint method of my custom delegate is as below,
>
>
> void MytDelegate::paint(QPainter *painter,
> const QStyleOptionViewItem &option,
> const QModelIndex &index) const {
>
> QStyleOptionViewItem checkBoxStyle(option);
>
> // set checkBoxStyle.rect here
>
> checkBoxStyle.state = QStyle::State_On;
This assignment overrides any state flags that were copied from 'option'. Use bitwise OR instead:
checkBoxStyle.state |= QStyle::State_On;
--
J-P Nurmi
More information about the Interest
mailing list