5

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.

Teit
  • 53
  • 1
  • 1
  • 4
  • Not sure I get the problem. What do you call "task bar"? Do you mean the Microsoft Windows task bar (it there is such a thing)? Here on Linux, xfce window environment, changing your message box from `(QtGui.QMessageBox.Information, ' ', 'Completed', buttons=QtGui.QMessageBox.Yes)` to `QtGui.QMessageBox(QtGui.QMessageBox.NoIcon, ' ', 'Completed', buttons=QtGui.QMessageBox.Yes)`, I have no icon at all. – jbm Feb 28 '16 at 10:04
  • yes, I mean Microsoft Windows task bar. With QtGui.QMessageBox.Information - all is well. I mean icon on header, top left. For example - for widget QtGui.QWidget() can use setWindowIcon(QtGui.QIcon('lg.png')). – Teit Feb 28 '16 at 12:04
  • Then, please consider adding a "windows" tag to your question. I'm afraid this is a Windows and or Qt/QtGui _for Windows_ problem. – jbm Feb 28 '16 at 12:19

1 Answers1

11

You can do it like this:

msgBox.setWindowIcon(QtGui.QIcon('PathToIcon/icon.png'))
Artem Zh.
  • 438
  • 5
  • 11