Setting the Same Icon as Application Icon in Task bar for pyqt5 application

Question:

I am finding trouble with attaching the same icon in the task bar manager for pyqt5 application as I did for the icon of pyqt5 application. I have attached below code for icon display in pyqt5, just need a bit help that how to code for displaying of same icon of Application to the task bar.
enter image description here

enter image description here

import sys
from SplashScreen import *
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QColor, qGray, QImage, QPainter, QPalette,QIcon
from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon('./cricket.png'))
    w = QWidget()
    w.resize(300,300)
    w.setWindowTitle('Quick Cricket')
    w.show()
    sys.exit(app.exec_())

Thanks in advance

Asked By: Abdul Rehman

||

Answers:

Guess What I found the Answer.

I used three lines of Code at the start of my application and then run the code and windows show me same icon as it was my logo.

import ctypes
myappid = 'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

What these lines do? So in short these lines will tell the window that this is my own registered application, so I will decide the icon of it.

I will give all credit to @DamonJW Stack Overflow Developer. Thanks @DamonJW.
Here is the link of solution

<
https://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7/1552105#1552105>

Answered By: Abdul Rehman

enter image description here

The solution is in this line

import ctypes
myappid = 'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
Answered By: lakhdar bekkari
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.