qtstylesheetqtstylesheetsqlabelqframe

QFrame's stylesheet affecting QLabel


I am using QFrame just to have colored border, since I couldn't find the a way to change color of the QDialog. So because of tampering with QFrame's border, it is also affecting the QLabel's look, is there any way to avoid this?

Edit: Here is the Stylesheet which I am using, where QLabels' doesn't have any effect. It's taking QFrames'

QWidget {
    background-color: black;
}
QLabel {
    color:white;
    border: solid 2px black;
    font: bold 19px Sans Serif;
}
QFrame {
    border: solid 2px white;
    border-radius: 4px;
}

Solution

  • Instead of using a type selector which matches all the instances of that class and its subclasses, use a class selector.

    So in your stylesheet, instead of using QFrame{...}, use .QFrame{border: 1px solid red;}. Note the . before the class name.

    See more about selector types here.