How to set application's taskbar icon in Windows 7

Viewed 42431

How do I set an application's taskbar icon in PyQt4?

I have tried setWindowIcon, and it successfully sets the icon in the top-left of the main window, but it does not affect the icon shown in the Windows 7 taskbar -- the taskbar icon remains the default Python pyw icon. Here is my code:

from PyQt4 import QtGui

app = QtGui.QApplication([])
mainwindow = QtGui.QMainWindow()
mainwindow.show()

app.setWindowIcon(QtGui.QIcon('chalk.ico'))
mainwindow.setWindowIcon(QtGui.QIcon('chalk.ico'))
app.exec_()

[update] I've tried placing the setWindowIcon() before the show(). I've tried it with other images, ico and png. Nothing helps.

3 Answers
Related