Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Need for setWIndowIcon()/setIcon()
Forum Update on Monday, May 27th 2025

Need for setWIndowIcon()/setIcon()

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 176 Views
  • 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.
  • P Offline
    P Offline
    Perdrix
    wrote 18 days ago last edited by
    #1

    If a Windows application has a .rc file that specifies a .ico file, or a macOS bundle contains a .icns file, do I need to call QWidget::setWindowIcon() or QWindow::setIcon()?

    Or perhaps better put under what circumstances do I need/not need to use these?

    Thanks
    David

    A 1 Reply Last reply 17 days ago
    0
    • P Perdrix
      18 days ago

      If a Windows application has a .rc file that specifies a .ico file, or a macOS bundle contains a .icns file, do I need to call QWidget::setWindowIcon() or QWindow::setIcon()?

      Or perhaps better put under what circumstances do I need/not need to use these?

      Thanks
      David

      A Offline
      A Offline
      Asperamanca
      wrote 17 days ago last edited by
      #2

      @Perdrix Docs on QWidget::setWindowIcon:

      This property only makes sense for windows. If no icon has been set, windowIcon() returns the application icon

      So you need to set if you want a diverging icon (e.g. for applications with multiple windows)

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote 17 days ago last edited by
        #3

        If you have a resource icon set up properly it will be used by default for all your windows. Usually you don't need to call these functions. You only call them when you want to change the icon at runtime, e.g. have different icon for one of the windows, like @Asperamanca said, or change the icon to indicate some state change in your app (logged in, connected to something etc.). There's usually a more idiomatic way to do the latter on most OSes though, so it's sometimes a bit of an abuse. Generally if you don't have an immediate idea how you could use that runtime change in a meaningful way don't use it.

        1 Reply Last reply
        1
        • P Offline
          P Offline
          Perdrix
          wrote 17 days ago last edited by Perdrix 5 Jul 2025, 08:42
          #4

          So, if I read that correctly, then I would normally only call QWindow::setIcon() on Linux?

          Is that right?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Asperamanca
            wrote 15 days ago last edited by
            #5

            I haven't done it, but it seems possible to set application icons on Linux, too....if you know the desktop environment beforehand.
            For full reference, please see https://doc.qt.io/qt-6/appicon.html

            1 Reply Last reply
            0

            1/5

            6 May 2025, 08:41

            • Login

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