setting QMessage IconPixmap to the PyQt built-in icons
-
Hi,
You have to do it in two steps:
- get the standard icon using QStyle::standardIcon
- get the pixmap from the icon using one of the QIcon::pixmap overload
-
Thank you .. this worked really well:
apply_pixmap = getattr(QStyle.StandardPixmap, "SP_DialogApplyButton") apply_icon = self.style().standardIcon(apply_pixmap) q_pixmap = apply_icon.pixmap(apply_pixmap) self.message.setIconPixmap(q_pixmap)
-
Out of curiosity, why are you using getattr ?
-
@SGaist said in setting QMessage IconPixmap to the PyQt built-in icons:
Out of curiosity, why are you using getattr ?
I have no specific reason to use getattr...
My objective is just to show this built-in icon in QMessage.
Is there a more straightforward way of doing it? -
@SGaist said in setting QMessage IconPixmap to the PyQt built-in icons:
Out of curiosity, why are you using getattr ?
I have no specific reason to use getattr...
My objective is just to show this built-in icon in QMessage.
Is there a more straightforward way of doing it?@explorer100 said in setting QMessage IconPixmap to the PyQt built-in icons:
getattr(QStyle.StandardPixmap, "SP_DialogApplyButton")
Is there a more straightforward way of doing it?QStyle.StandardPixmap.SP_DialogApplyButton
(PySide6/PyQt6) should work for this. (Or probablyQStyle.SP_DialogApplyButton
if PySide2/PyQt5.) -
Thank you.. that worked for PyQt6
QStyle.StandardPixmap.SP_DialogApplyButton
-
Hi,
You have to do it in two steps:
- get the standard icon using QStyle::standardIcon
- get the pixmap from the icon using one of the QIcon::pixmap overload
Just to complete the discussion, is there a simpler way to do this than:
apply_pixmap = QStyle.StandardPixmap.SP_DialogApplyButton
apply_icon = self.style().standardIcon(apply_pixmap)
q_pixmap = apply_icon.pixmap(apply_pixmap)Thank you all for the advice.
-
apply_icon = self.style().standardIcon(QStyle.StandardPixmap.SP_DialogApplyButton) q_pixmap = apply_icon.pixmap(QStyle.StandardPixmap.SP_DialogApplyButton)
-
apply_icon = self.style().standardIcon(QStyle.StandardPixmap.SP_DialogApplyButton) q_pixmap = apply_icon.pixmap(QStyle.StandardPixmap.SP_DialogApplyButton)
That won't work because you don't have apply_pixmap anymore to use.
I think you meat this:
apply_icon = self.style().standardIcon(QStyle.StandardPixmap.SP_DialogApplyButton)
q_pixmap = apply_icon.pixmap(QStyle.StandardPixmap.SP_DialogApplyButton) -
That won't work because you don't have apply_pixmap anymore to use.
I think you meat this:
apply_icon = self.style().standardIcon(QStyle.StandardPixmap.SP_DialogApplyButton)
q_pixmap = apply_icon.pixmap(QStyle.StandardPixmap.SP_DialogApplyButton)@explorer100 Indeed, and fixed.