Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QPushButton文本上的阴影效果_C++_Qt_Qtstylesheets_Qstyle - Fatal编程技术网

C++ QPushButton文本上的阴影效果

C++ QPushButton文本上的阴影效果,c++,qt,qtstylesheets,qstyle,C++,Qt,Qtstylesheets,Qstyle,如何在QPushButton文本上设置阴影效果 我可以使用QGraphicsDropShadowEffect在整个QPushButton上设置阴影,但是,我无法找到直接设置QButton内文本效果的方法 编辑: 我尝试了以下方法,不确定语法是否正确 在.qss文件中: MyButton::text { shadow: palette(dark); } 我通过以下方式设置按钮的阴影效果: QGraphicsDropShadowEffect* effect = new QGraphicsD

如何在QPushButton文本上设置阴影效果

我可以使用QGraphicsDropShadowEffect在整个QPushButton上设置阴影,但是,我无法找到直接设置QButton内文本效果的方法

编辑:

我尝试了以下方法,不确定语法是否正确

在.qss文件中:

MyButton::text
{
    shadow: palette(dark);
}
我通过以下方式设置按钮的阴影效果:

QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect( );
    effect->setBlurRadius( 5 );
    mStartButton->setGraphicsEffect( effect );
试试这个:

设置QLabel iside QPushButton而不是简单文本。然后对标签应用阴影效果

您可能需要添加额外的代码,以便将标签居中放置在按钮内

mStartButton->setText("");
QLabel *label = new QLabel(mStartButton);
label->setText("<b>Button</b>");
QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect( );
effect->setBlurRadius( 5 );
label ->setGraphicsEffect( effect );
mStartButton->setText(“”);
QLabel*标签=新的QLabel(mStartButton);
标签->设置文本(“按钮”);
QGraphicsDropShadowEffect*effect=新的QGraphicsDropShadowEffect();
效应半径(5);
标签->设置图形效果(效果);

添加一些代码将有助于回答问题