Perfect. Thank you very much. It works perfect.
So that other people, if they have the same problem here have the solution. It's very simple and I did not fall for something so simple. In the properties where I assign the texts and icons we call a method that modifies the margins. Only that.
For example:
#import PyQt5 or PySide (To the taste of the client)
class Test(QDialog):
def __init__(self, parent: QDialog = None):
super().__init__(parent)
self.__row_Text = None
@property
def row_Text(self) -> str:
return self.__row_Text
@row_Text.setter
def row_Text(self, value: str):
self.__row_Text = value
self.updateFancyBackground()
self.repaint()
def updateFancyBackground(self):
# I liked the name Fancy Background
if self.__row_Text is not None:
margins = self.layout().contentsMargins()
margins.setTop(24)
self.layout().setContentsMargins(margins)
def paintEvent(self, event: QPaintEvent):
# Your code for height = 24
pass
Many thanks to "SGaist" and "mrjj", for giving me the idea to solve it.