문제

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 );
도움이 되었습니까?

해결책

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 );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top