How to control background border size of QDialog with QStyleSheet

598 Views Asked by At

Using stylesheets, if I set background-color of a QDialog, I don't seem to be able to control the width of the visible colour - the gap between the content and the actual border. For example if I create a QDialog with only a QListWidget on it, in a QGridLayout, I see the background-color appear as a border around the QListWidget. I would like to make this thinner.

How can I reduce this "border"? It looks as thought background-clip would work if QDialog supported the box model.

I am on 4.7 if it makes any difference

1

There are 1 best solutions below

0
On BEST ANSWER

That's the layout border. You can reduce it from the design editor by selecting yout QDialog then adjusting the layoutLeftMargin/layoutTopMargin/layoutRightMargin/layoutBottomMargin properties.

You can also set the border width by code by calling setContentMargins on the layout. For example:

ui->gridLayout->setContentsMargins(3,3,3,3); // sets the qdialog border width to 3px.