The various built-in icons used by Qt can be retrieved via the QStyle.standardIcon method.
The QMessageBox
class also has a method to extract the pixmap for each QMessageBox.Icon, but it's not part of the public API. Here's a PyQt/PySide port of it:
def messageBoxIcon(mbicon, widget=None):
if widget is not None:
style = widget.style()
else:
style = QtGui.QApplication.style()
size = style.pixelMetric(
QtGui.QStyle.PM_MessageBoxIconSize, None, widget)
if mbicon == QtGui.QMessageBox.Information:
icon = style.standardIcon(
QtGui.QStyle.SP_MessageBoxInformation, None, widget)
elif mbicon == QtGui.QMessageBox.Warning:
icon = style.standardIcon(
QtGui.QStyle.SP_MessageBoxWarning, None, widget)
elif mbicon == QtGui.QMessageBox.Critical:
icon = style.standardIcon(
QtGui.QStyle.SP_MessageBoxCritical, None, widget)
elif mbicon == QtGui.QMessageBox.Question:
icon = style.standardIcon(
QtGui.QStyle.SP_MessageBoxQuestion, None, widget)
else:
icon = QtGui.QIcon()
if not icon.isNull():
return icon.pixmap(size, size)
return QtGui.QPixmap()