4
votes

I am trying to change the appearance of a QGroupbox. The problem is about the border of it. After changing the style sheet, the text of the groupbox is not aligned with the border anymore. How can this be solved?

In the first picture, the border is well aligned with the text:

The style sheet related to this QGroupBox is like this:

QGroupBox{
background-color: rgb(0,80,120);
color: white;
font: 14pt "MS Shell Dlg 2";
font: bold;
text-align:center;
}

In the second picture, the border is aligned with the bottom of the text:

The style sheet related to QGroupBox above is like this:

QGroupBox{
background-color: rgb(0,80,120);
color: white;
font: 14pt "MS Shell Dlg 2";
font: bold;
text-align:center;
border-color: rgb(255,255,255);
border-width: 2px;
border-style: solid;
border-radius: 9px;
padding: 2px;
}

As you can see, when I add border related parameters, text alignment somehow changes. I want the first style but with the text aligned properly with the border. What is wrong?

Thanks.

1
Its actually not the text but the border thats being corrupted. It moves from top indent to upper edge.Sebastian Lange

1 Answers

1
votes

Nothing wrong. But you should adjust margin / padding. And sub controls. I propose you to read Qt stylesheet reference.