Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to change size of QGraphicsDropShadowEffect



  • Is there a way to change the size of QGraphicsDropShadowEffect? The Size is the same as the image it's attached to just with an offset. What I would like to achieve is something like this:

    4fd83569-f612-4a79-b3a7-4f8b3c16973f-image.png

    Left is plain QGraphicsDropShadowEffect, the shadow is below and right because there is an offset of 5px on x and y. On the right there is shadow on all sides, currently I can't figure out how to achieve this.
    An option is probably overwriting the draw method but how to draw this blurry shadow?



  • @dporobic Hi. Maybe using setBlurRadius and setOffset work, like the following code:

     QGraphicsDropShadowEffect *bodyShadow = new QGraphicsDropShadowEffect;
        bodyShadow->setBlurRadius(30);
        bodyShadow->setColor(QColor(0,0,0,160));
        bodyShadow->setOffset(0);
        ui->label_2->setGraphicsEffect(bodyShadow);
    


  • @nanor not a bad idea, that's what I get:

    15616d28-f92d-4de0-8ebd-88cf7f3afe8b-image.png

    Could be a bit darker I guess. I have tried playing around with the radius but that seems the best result I could get.

    Any other alternative?



  • @dporobic to get a darker shadow, you can increase the forth element of QColor (which is the opacity)



  • @nanor that on the screenshot is already the maximum.


Log in to reply