Skip to content

Instantly share code, notes, and snippets.

@neel
Created June 20, 2009 18:35
Show Gist options
  • Save neel/133232 to your computer and use it in GitHub Desktop.
Save neel/133232 to your computer and use it in GitHub Desktop.
void ArthurStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const{
Q_ASSERT(option);
switch (element) {
case PE_FrameFocusRect:
break;
case PE_IndicatorRadioButton:
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver);
painter->save();
QPixmap radio;
if(hover){
qDebug() << "Hover on Radio";
drawHoverRect(painter, widget->rect());
}
if (button->state & State_Sunken)
radio = cached(":res/images/radiobutton-on.png");
else if (button->state & State_On)
radio = cached(":res/images/radiobutton_on.png");
else
radio = cached(":res/images/radiobutton_off.png");
painter->drawPixmap(button->rect.topLeft(), radio);
painter->restore();
}
break;
case PE_IndicatorCheckBox:
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
bool hover = (button->state & State_Enabled) && (button->state & State_MouseOver);
painter->save();
QPixmap radio;
if (hover){
qDebug() << "Hover on CheckBox";
drawHoverRect(painter, widget->rect());
}
if (button->state & State_Sunken)
radio = cached(":res/images/radiobutton-on.png");
else if (button->state & State_On)
radio = cached(":res/images/radiobutton_on.png");
else
radio = cached(":res/images/radiobutton_off.png");
painter->drawPixmap(button->rect.topLeft(), radio);
painter->restore();
}
break;
........
........
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment