Hello,
I am redifining a customized Style for my desktop application in which I would like to draw buttons with shadow effects.
To do so, I tried to overload the drawPrimitive method in my class which is an extension of QMotifStyle (see the following code).
void MyStyle_c::drawPrimitive(PrimitiveElement element,
const QStyleOption *option,
QPainter *painter,
const QWidget *widget) const
{
int x, y, width, height;
option->rect.getRect(&x, &y, &width, &height);
switch (element) {
....
case PE_PanelButtonCommand:
{
.......
painter->setRenderHint(QPainter::Antialiasing, true);
QGraphicsRectItem * item = new QGraphicsRectItem(x,y,width,height);
QGraphicsDropShadowEffect * effect = new QGraphicsDropShadowEffect ;
effect->setBlurRadius(5);
effect->setColor(Qt::blue);
item->setGraphicsEffect(effect); /* NO EFFECT !*/
painter->drawPath(item->shape());
}
break;
....
default:
QMotifStyle::drawPrimitive(element, option, painter, widget);
}
}
It’s drawn properly but without any effect. Could you please tell me why ? What am I doing wrong ?
Thanks you a lot
Habib
↧