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,
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 :