How to change the app's icon MacOS and windows on Qt6.1.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.icnsMy 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"));
} -
@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.
-
@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.icnsYour 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
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"));