T .
T .

Reputation: 4944

Accessing padding from stylesheet in QT

I have a custom QWidget subclass that lays out a number of children. In my stylesheet I define a background, which works fine. I also define padding, which doesn't work. I clearly need to provide support for this myself.

To do that, I need to be able to find out what padding is set in the stylesheet for my widget. I do not wish to parse the stylesheet myself, that would not make much sense. How can I access the top, left, bottom and right padding set in the stylesheet?

Thanks in advance,

Upvotes: 2

Views: 1849

Answers (1)

alexisdm
alexisdm

Reputation: 29896

Your custom widget has to inherit from a widget that supports the "box model" (you can find which widgets do on that page), and then you can use QWidget::contentsRect() to get the... content rectangle :

Qt Box Model

Upvotes: 5

Related Questions