Question

How do I set a drop-shadow effect on a QPushButton text?

I could set shadow on the entire QPushButton using QGraphicsDropShadowEffect, I however, am not able to find a way to directly set the effect of text inside the QButton.

Edit:

I tried the following, not sure if the syntax is correct

in the .qss file:

MyButton::text
{
    shadow: palette(dark);
}

I set the button's drop shadow effect by:

QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect( );
    effect->setBlurRadius( 5 );
    mStartButton->setGraphicsEffect( effect );
Was it helpful?

Solution

Try this:

Set a QLabel iside QPushButton rather than simple text. Then apply shadow effect to the label.

You may need to add extra code for centering the label inside the pushbutton.

mStartButton->setText("");
QLabel *label = new QLabel(mStartButton);
label->setText("<b>Button</b>");
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect( );
effect->setBlurRadius( 5 );
label ->setGraphicsEffect( effect );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top