PyQt5.QIcon Is not showing any icon

736 views Asked by At

I am trying to show the icon in the window bar and this is not simply working. I tried several solutions but still it doesn't work. Any solution for this code?

import os
from PyQt5.QtCore import *
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *


class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.browser = QWebEngineView()
        self.browser.setUrl(QUrl('http://gmail.com'))
        self.setCentralWidget(self.browser)
        self.showMaximized()

        self.setWindowTitle('G')
        self.setWindowIcon(QIcon(os.path.join('cil.png')))
        self.show()


app = QApplication(sys.argv)

window = MainWindow()
app.exec_()


1

There are 1 answers

0
AudioBubble On

Try putting the icon like this

icon = QIcon()
icon.addPixmap(QtGui.QPixmap())  #add full path or respective path to the icon image inside QtGui.QPixmap()
self.setWindowIcon(icon)