Skip to content

Commit 475a8bd

Browse files
zhiyiYoapooreapo
andcommitted
修复按钮图标为空时的布局问题
Co-authored-by: apooreapo <[email protected]>
1 parent 16ba1c2 commit 475a8bd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

qfluentwidgets/components/widgets/button.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ def _postInit(self):
5454
pass
5555

5656
def setIcon(self, icon: Union[QIcon, str, FluentIconBase]):
57-
self.setProperty('hasIcon', icon is not None)
57+
if icon is None or (isinstance(icon, QIcon) and icon.isNull()):
58+
self.setProperty('hasIcon', False)
59+
else:
60+
self.setProperty('hasIcon', True)
61+
5862
self.setStyle(QApplication.style())
5963
self._icon = icon or QIcon()
6064
self.update()

0 commit comments

Comments
 (0)