Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Window icon is not visible.
Qt 6.11 is out! See what's new in the release blog

Window icon is not visible.

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 4 Posters 5.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yashi95
    wrote on last edited by yashi95
    #1

    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

    JonBJ F 2 Replies Last reply
    0
    • Y yashi95

      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

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @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?

      Y 1 Reply Last reply
      0
      • JonBJ JonB

        @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?

        Y Offline
        Y Offline
        yashi95
        wrote on last edited by yashi95
        #3

        @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

        JonBJ 1 Reply Last reply
        0
        • Y yashi95

          @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

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @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.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

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

            If not working, then take a look here.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • Y yashi95

              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

              F Offline
              F Offline
              fringetos
              wrote on last edited by fringetos
              #6

              @yashi95

              You can use QApplication.setWindowIcon().

              In your code:

              myApp = QApplication(sys.argv)
              myApp.setWindowIcon(QIcon("sharp-osa.png"))
              window = Window()
              window.show()

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved