Skip to content

Commit f00ad28

Browse files
committed
Revert QwtLegendLabel_PrivateData fix
1 parent c559bd2 commit f00ad28

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

qwt/legend.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def __init__(self):
176176
self.isDown = False
177177
self.spacing = MARGIN
178178
self.legendData = QwtLegendData()
179-
self.icon = None
179+
self.icon = QPixmap()
180180

181181

182182
class QwtLegendLabel(QwtTextLabel):
@@ -294,7 +294,7 @@ def icon(self):
294294
295295
:py:meth:`setIcon()`
296296
"""
297-
return QPixmap() if self.__data.icon is None else self.__data.icon
297+
return self.__data.icon
298298

299299
def setSpacing(self, spacing):
300300
"""
@@ -312,7 +312,7 @@ def setSpacing(self, spacing):
312312
mgn = self.contentsMargins()
313313
margin = max([mgn.left(), mgn.top(), mgn.right(), mgn.bottom()])
314314
indent = margin + self.__data.spacing
315-
if self.__data.icon is not None:
315+
if self.__data.icon.width() > 0:
316316
indent += self.__data.icon.width() + self.__data.spacing
317317
self.setIndent(indent)
318318

@@ -390,8 +390,7 @@ def sizeHint(self):
390390
:return: a size hint
391391
"""
392392
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]))
395394
if self.__data.itemMode != QwtLegendData.ReadOnly:
396395
sz += buttonShift(self)
397396
return sz
@@ -410,7 +409,7 @@ def paintEvent(self, e):
410409
painter.translate(shiftSize.width(), shiftSize.height())
411410
painter.setClipRect(cr)
412411
self.drawContents(painter)
413-
if self.__data.icon is not None:
412+
if not self.__data.icon.isNull():
414413
iconRect = QRect(cr)
415414
iconRect.setX(iconRect.x() + self.margin())
416415
if self.__data.itemMode != QwtLegendData.ReadOnly:

0 commit comments

Comments
 (0)