Important: Please read the Qt Code of Conduct -

SetStyleSheet to QPushButton - box-shadow

  • Hi,
    I have a question. Is there a possibility to set shadoww to the pushbutton?

    Now, I have:

    "border-width: 2px;"
    "border-color: #999999;"
    "border-radius: 10px;"
    "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
    "stop: 0 #CCCCCC, stop: 1 #AAAAAA);}";

    Now I want to set box-shadow
    "link to example shadow":
    and I tried to set it:

    "box-shadow: 10px 10px 5px rgba(182, 191, 193, 0.5);"

    But there is no effect. Is it possible to set the shadow? Or I do sth wrong?

  • Hiii.

    You can use QFrame with QPushbutton and can get desired shadow effects.
    Set the following properties:-
    1)frameShape - Panel
    2)frameShadow - Raised
    3)lineWidth - 5
    4)midelineWidth - 2

  • But I also change shape of button and other properties, so I have to use setStyleSheet (I think so, if I am wrong, please correct me).

  • Only an idea:
    Perhaps you may succeed with border-style "see: ":
    Haven't tried it yet but it seems flexible enough to paint the shadow, too (groove && / || ridge).

  • Yes, I thought about it, but I have to create couple of styles of buttons, and one of option was to use border-style:outset/inset, second option was to set border width, and now I want to add some shadow in third style.

  • You may even mix the styles for top, bottom, right & left lines with border-top-style etc.

  • Ok, I will try, thanks

  • Try this..

    QWidget vpcWidget = new QWidget();

    QPushButton *pBtn = new QPushButton();


    QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();

    effect->setBlurRadius(1); //Adjust accordingly

    effect->setOffset(3,3); //Adjust accordingly



    Hope it helps

Log in to reply