[Interest] Issue in drawing CheckBox using QStyle::drawPrimitive

Lijo Antony lta at one.com
Tue Nov 27 14:54:38 CET 2012

Hi All,

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;
&checkBoxStyle, painter);


However, this checkbox is always drawn as grayed out, like a disabled 
QCheckBox. I am trying to make this checkbox to be drawn just like an 
active QCheckBox. I tried to tweak the palette of the QStyleOption 
without any luck. Would you please tell me how to do this?

Thanks in advance.


More information about the Interest mailing list