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

QGraphicsDropShadowEffect cut off by margin



  • I am using a QScrollArea with a QVBoxLayout::setAlignment(Qt::AlignHCenter | Qt::AlignTop); so that everytime i add a QFrame in it, they just pile on top of each others without stretching.

    I wanted the QFrame to look detached from it and i thought using a boxshadow would be the best for it, i found out that QGraphicsDropShadowEffect was the only way to make it happen so i added background color to the QFrame and added this bit:
    QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(this);
    shadowEffect->setYOffset(4);
    shadowEffect->setXOffset(2);
    shadowEffect->setBlurRadius(10);
    setGraphicsEffect(shadowEffect);

    The shadow appears but i have a problem with margins and scrolling, the shadow will not appear because when scrolling it will stop at the very edge of the frame, making the shadow outside of the displayed area, same thing will happen with margins.

    Here is a screenshot showing what happens with a margin-right: screenshot

    As you can see, the shadow on the right is truncated because of the margin, also, if i were to reduce the window height and force the scroll bar to appear, scroll down to the maximum would just stop at the border itself, making the shadow not visible.


Log in to reply