How to change icon in title QMessageBox in Qt, python

Teit picture Teit · Feb 28, 2016 · Viewed 7.6k times · Source

How to change or delete icon in title QMessageBox in Qt, python. I have next cod:

msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, ' ', 'Completed',
                           buttons=QtGui.QMessageBox.Yes)
msgBox.setWindowFlags(QtCore.Qt.FramelessWindowHint |
                      QtCore.Qt.WindowTitleHint)
msgBox.exec_()

When msgBox appear in monitor, no icon and text in title, but on task bar I see the standart icon Windows. it's not beautiful.

Answer

Artem Zh. picture Artem Zh. · Mar 16, 2016

You can do it like this:

msgBox.setWindowIcon(QtGui.QIcon('PathToIcon/icon.png'))