문제

I'm trying to use style sheets to customize a QPushButton. Using the following style sheet I have create a button with a gray background and a black boarder around it :

 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);

I'd like to add a second border around the button using the style sheet. I tried setting a padding color, but that does not seem to do anything. Is it possible to add a second border?

도움이 되었습니까?

해결책

If you would like to use only style sheet it's probably not possible.

Similar solution is to change border-style to double, e.g.

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);

All available borders.

Relating to padding it's not possible to set a color for it. Explain how it look is here.

다른 팁

Wrap the button with a QFrame, and style that QFrame in addition to the QPushButton.

//    ------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);

Hope that helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top