Pregunta

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?

¿Fue útil?

Solución

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.

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top