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 change the app's icon MacOS and windows on Qt6.1.1?
Qt 6.11 is out! See what's new in the release blog

How to change the app's icon MacOS and windows on Qt6.1.1?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 2.0k 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.
  • A Offline
    A Offline
    angelyouyou
    wrote on last edited by angelyouyou
    #1

    I define and put ICON at my .pro file and .icns file at Resources/icons directory.
    But it does work.
    When I run the app, the icon on docker is transparent in MacOS.
    My project zip link is here.

    ICON +=
    Resources/icons/app.icns

    My control initialization code is:
    void Initialize::LoadControlls(Text2PcapWidget *win) {
    win->setWindowFlags(Qt::Dialog);
    win->setFixedSize(UI_SIZE_WIDGET_WIDTH, UI_SIZE_WIDGET_HEIGHT);
    //win->setWindowIcon(QIcon(":/icons/icons/app.icns"));
    }

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2

      @angelyouyou How to change the app's icon MacOS and windows on Qt6.1.1?

      As it says in the documentation: https://doc.qt.io/qt-6/appicon.html
      Since you are using qmake and your PRO file does not already contain a Windows resource (RC) file:

      win32: RC_ICONS = Resources/icons/app.ico
      macx: ICON = Resources/icons/app.icns
      

      Your current PRO file uses "+=" rather than "=" , which may be a problem (I have no Mac)

      The icon above is not the same thing as the window icon your code tried to set with setWindowIcon(): generally that will default to the application icon but it can be overridden. Your Mac .icns file should be at ":/icons/app.icns" if I am (manually) reading your qrc file correctly.

      A 1 Reply Last reply
      1
      • A Offline
        A Offline
        angelyouyou
        wrote on last edited by
        #3

        @ChrisW67 said in How to change the app's icon MacOS and windows on Qt6.1.1?:

        @angelyouyou How to change the app's icon MacOS and windows on Qt6.1.1?
        As it says in the documentation: https://doc.qt.io/qt-6/appicon.html
        Since you are using qmake and your PRO file does not already contain a Windows resource (RC) file:
        win32: RC_ICONS = Resources/icons/app.ico
        macx: ICON = Resources/icons/app.icns

        Your current PRO file uses "+=" rather than "=" , which may be a problem (I have no Mac)
        The icon above is not the same thing as the window icon your code tried to set with setWindowIcon(): generally that will default to the application icon but it can be overridden. Your Mac .icns file should be at ":/icons/app.icns" if I am reading your qrc file correctly.

        Thanks very much for your help.
        When I use the below ICON resources without '+' in .pro file, the app's icon is transparent(just like the picture below).
        ICON =
        Resources/icons/app.icns
        c2d876b1-1f5d-4e1b-bcdd-aef8214ba896-image.png

        When I comment the Resource ICON code in .pro file and use the, the app's icon is altransparent(just like the picture below).

        win->setWindowIcon(QIcon(":/icons/app.icns"));
        4e581e49-0fc0-42c7-9022-56938b0728d0-image.png

        1 Reply Last reply
        0
        • C ChrisW67

          @angelyouyou How to change the app's icon MacOS and windows on Qt6.1.1?

          As it says in the documentation: https://doc.qt.io/qt-6/appicon.html
          Since you are using qmake and your PRO file does not already contain a Windows resource (RC) file:

          win32: RC_ICONS = Resources/icons/app.ico
          macx: ICON = Resources/icons/app.icns
          

          Your current PRO file uses "+=" rather than "=" , which may be a problem (I have no Mac)

          The icon above is not the same thing as the window icon your code tried to set with setWindowIcon(): generally that will default to the application icon but it can be overridden. Your Mac .icns file should be at ":/icons/app.icns" if I am (manually) reading your qrc file correctly.

          A Offline
          A Offline
          angelyouyou
          wrote on last edited by
          #4

          @ChrisW67
          maybe the icns is not suitable?

          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