Say that you have a shape and a label from which you want to cast a shadow.
You can use QGraphicsDropShadowEffect like this:
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; effect->setBlurRadius(5); effect->setXOffset(5); effect->setYOffset(5); effect->setColor(Qt::black); label->setGraphicsEffect(effect);
And the effect will be:

The disadvantage of this effect is that if you apply it to a widget, all its children inherit it. This can be problematic if you apply the effect to a widget with a large number of widgets, because it can slow down the rendering time. But for your example, this is fine and recommended.
For more information about the effects in Qt check out the QGraphicsEffect class, from which QGraphicsDropShadowEffect is also derived.
Iuliu source share