@@ -308,7 +308,8 @@ def setSpacing(self, spacing):
308308 spacing = max ([spacing , 0 ])
309309 if spacing != self .__data .spacing :
310310 self .__data .spacing = spacing
311- margin = max (self .getContentsMargins ())
311+ mgn = self .contentsMargins ()
312+ margin = max ([mgn .left (), mgn .top (), mgn .right (), mgn .bottom ()])
312313 indent = margin + self .__data .spacing
313314 if self .__data .icon .width () > 0 :
314315 indent += self .__data .icon .width () + self .__data .spacing
@@ -912,12 +913,12 @@ def renderLegend(self, painter, rect, fillBackground):
912913 legendLayout = self .__data .view .contentsWidget .layout ()
913914 if legendLayout is None :
914915 return
915- left , right , top , bottom = self .layout ().getContentsMargins ()
916+ margins = self .layout ().contentsMargins ()
916917 layoutRect = QRect ()
917- layoutRect .setLeft (math .ceil (rect .left ()) + left )
918- layoutRect .setTop (math .ceil (rect .top ()) + top )
919- layoutRect .setRight (math .ceil (rect .right ()) - right )
920- layoutRect .setBottom (math .ceil (rect .bottom ()) - bottom )
918+ layoutRect .setLeft (math .ceil (rect .left ()) + margins . left () )
919+ layoutRect .setTop (math .ceil (rect .top ()) + margins . top () )
920+ layoutRect .setRight (math .ceil (rect .right ()) - margins . right () )
921+ layoutRect .setBottom (math .ceil (rect .bottom ()) - margins . bottom () )
921922 numCols = legendLayout .columnsForWidth (layoutRect .width ())
922923 itemRects = legendLayout .layoutItems (layoutRect , numCols )
923924 index = 0
@@ -949,7 +950,8 @@ def renderItem(self, painter, widget, rect, fillBackground):
949950 if label is not None :
950951 icon = label .data ().icon ()
951952 sz = icon .defaultSize ()
952- margin = max (label .getContentsMargins ())
953+ mgn = label .contentsMargins ()
954+ margin = max ([mgn .left (), mgn .top (), mgn .right (), mgn .bottom ()])
953955 iconRect = QRectF (
954956 rect .x () + margin ,
955957 rect .center ().y () - 0.5 * sz .height (),
0 commit comments