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. How to get the actual main window / application icon(s) regadless of how they have been set?
Forum Updated to NodeBB v4.3 + New Features

How to get the actual main window / application icon(s) regadless of how they have been set?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    I'm testing on Windows, but I'm making a cross-platform app for Win / Linux / Mac.

    I need QApplication::windowIcon() to work. The problem is it works if I called "setWindowIcon" previously, but not if I've set an icon from a resource file. Is there any other, versatile way to get the icon? If not, how can I get the right icon from resource file, assuming I don't want to hardcode its resource name? I. e., how to determine and retrieve it at runtime dynamically so that the code remains working when icon resource name changes?

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

      Hi,

      Use an alias for the resource so even if you change the file name as long as keep the same alias you're good.

      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
      0
      • V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #3

        But what if I've set the icon by specifying .rc file on Windows or .icns on Mac, without even having a .qrc file? How to retrieve that icon at runtime, with all its sizes?

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

          If you want absolutely the same file then just embed it in the resource file

          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
          0

          • Login

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