Qt 如何使用样式表创建具有两个边框的QpushButton?

Qt 如何使用样式表创建具有两个边框的QpushButton?,qt,stylesheet,Qt,Stylesheet,我正在尝试使用样式表来定制QPushButton。使用以下样式表,我创建了一个带有灰色背景和黑色边框的按钮: background-color: rgb(97, 97, 97); border-style: outset; border-width: 1px; border-color: rgb(0, 0, 0); border-radius: 4px; color:rgb(255, 255, 255); 我想使用样式表在按钮周围添加第二个边框。我尝试设置填充颜色,但似乎没有任何

我正在尝试使用样式表来定制QPushButton。使用以下样式表,我创建了一个带有灰色背景和黑色边框的按钮:

 background-color: rgb(97, 97, 97); 
 border-style: outset;
 border-width: 1px;
 border-color: rgb(0, 0, 0);
 border-radius: 4px;
 color:rgb(255, 255, 255);

我想使用样式表在按钮周围添加第二个边框。我尝试设置填充颜色,但似乎没有任何效果。是否可以添加第二个边框?

用QFrame包装按钮,并在QPushButton之外设置QFrame的样式

//    ------Widget------
//      ------hbox----------
//        ------QFrame---------
//          ------frameLayout-----
//            ------QPushButton-----

QHBoxLayout * hbox = new QHBoxLayout;
QFrame * frame = new QFrame;
QPushButton * button = new QPushButton("Double Border Button");
QHBoxLayout * frameLayout = new QHBoxLayout;
frameLayout->addWidget(button);
frame->setLayout(frameLayout);
hbox->addWidget(frame);
this->setLayout(hbox);

希望这能有所帮助。

如果您只想使用样式表,可能是不可能的

类似的解决方案是将边框样式更改为双边框,例如

全部

关于填充,无法为其设置颜色。解释一下它的外观

background-color: rgb(97, 97, 97);
border-style: double;
border-width: 3px;
border-color: rgb(0, 0, 0);
border-radius: 4px;
color:rgb(255, 255, 255);