Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Window icon is not visible.



  • Hi,
    I trying show icon in window but is not visible in window.
    bellow attaching some sample what i tried

    from PySide2.QtWidgets import QApplication, QWidget
    import sys
    from PySide2.QtGui import QIcon
    
    
    
    class Window(QWidget):
        def __init__(self):
            super().__init__()
    
            self.setWindowTitle("Setting Icon")
            self.setGeometry(300,300, 500,400)
            self.setWindowIcon(QIcon("sharp-osa.png"))
    
    myApp = QApplication(sys.argv)
    window = Window()
    window.show()
    
    
    myApp.exec_()
    sys.exit(0)
    

    is something missing in code.
    Python version3.8.2

    e708ae19-b079-4ddc-a2ef-d68b79153a9c-image.png

    Is not setting icon in window left corner, setting icon as application icon



  • @yashi95
    https://doc.qt.io/qt-5/qicon.html#QIcon-4

    If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.

    One guess: file not found. How do we know where your file is and what the app's working directory is?

    Or: do we even know if GNOME sets any window icons "in window left corner", I'm not sure I've seen that anywhere else?



  • @JonB

    My file directory in the same folder where my app is running. I am not getting any error like "file not found" icon is setting but in the taskbar is setting like if u see in an image which I share right hand side if you see taskbar one red cross icon



  • @yashi95 said in Window icon is not visible.:

    I am not getting any error like "file not found" icon

    There would be nowhere for an error to come from, if it were the case. I do not know whether GNOME would show any "red cross".

    I previously said:

    Or: do we even know if GNOME sets any window icons "in window left corner", I'm not sure I've seen that anywhere else?

    If you think it should be setting a "window left corner" icon, can you show me any GNOME window which has that? Is it supported?

    I only know you can set a GNOME application icon, which shows in the taskbar.


  • Lifetime Qt Champion

    Hi,

    I think you have to call QApplication::setWindowIcon for that one.

    If not working, then take a look here.


Log in to reply