@@ -176,7 +176,7 @@ def __init__(self):
176
176
self .isDown = False
177
177
self .spacing = MARGIN
178
178
self .legendData = QwtLegendData ()
179
- self .icon = None
179
+ self .icon = QPixmap ()
180
180
181
181
182
182
class QwtLegendLabel (QwtTextLabel ):
@@ -294,7 +294,7 @@ def icon(self):
294
294
295
295
:py:meth:`setIcon()`
296
296
"""
297
- return QPixmap () if self . __data . icon is None else self .__data .icon
297
+ return self .__data .icon
298
298
299
299
def setSpacing (self , spacing ):
300
300
"""
@@ -312,7 +312,7 @@ def setSpacing(self, spacing):
312
312
mgn = self .contentsMargins ()
313
313
margin = max ([mgn .left (), mgn .top (), mgn .right (), mgn .bottom ()])
314
314
indent = margin + self .__data .spacing
315
- if self .__data .icon is not None :
315
+ if self .__data .icon . width () > 0 :
316
316
indent += self .__data .icon .width () + self .__data .spacing
317
317
self .setIndent (indent )
318
318
@@ -390,8 +390,7 @@ def sizeHint(self):
390
390
:return: a size hint
391
391
"""
392
392
sz = QwtTextLabel .sizeHint (self )
393
- icon_height = 0 if self .__data .icon is None else self .__data .icon .height ()
394
- sz .setHeight (max ([sz .height (), icon_height + 4 ]))
393
+ sz .setHeight (max ([sz .height (), self .__data .icon .height () + 4 ]))
395
394
if self .__data .itemMode != QwtLegendData .ReadOnly :
396
395
sz += buttonShift (self )
397
396
return sz
@@ -410,7 +409,7 @@ def paintEvent(self, e):
410
409
painter .translate (shiftSize .width (), shiftSize .height ())
411
410
painter .setClipRect (cr )
412
411
self .drawContents (painter )
413
- if self .__data .icon is not None :
412
+ if not self .__data .icon . isNull () :
414
413
iconRect = QRect (cr )
415
414
iconRect .setX (iconRect .x () + self .margin ())
416
415
if self .__data .itemMode != QwtLegendData .ReadOnly :
0 commit comments