Application Icon not showing for Qt apps in Windows
-
wrote on 18 May 2020, 13:50 last edited by
Hello,
I recently replaced my system and updated my Qt project to Qt 5.14 built with CMake 3.17 and Visual Studio 2017. Everything is workfing fine now, except that the icons are not being shown for the Windows executable. I'm linking the resource file the way it's described in this page:
https://doc.qt.io/qt-5/appicon.htmlUsing this method the application was showing the icon in my previous setup.
Does anybody know what am I missing?
I have tried with many different generated rc and icon files.
I've also generated a Visual Studio 2017 GUI app. This one shows the icons correctly, and it uses a RegisterClassExW call to define the icon for the application.
WNDCLASSEXW wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINPROJ)); wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_WINPROJ); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); return RegisterClassExW(&wcex);
Is there a way to call RegisterClassExW from Qt?
I've uploaded a sample project (QCollidingMice) with a CMake configuration file and a VS generated rc file. This is the same setup I'm using for my application.
Thank you
-
wrote on 18 May 2020, 14:05 last edited by Bonnie
I've set my app icon with RC_ICONS in windows.
It works very well.
Since your app shows the old icon, I think it works too, but not updated.
(RC_ICONS will also generate .rc file.)
Did you try cleaning the project and then run qmake again?
*Sorry, I don't use CMAKE QT, don't know how to do it with CMAKE. -
wrote on 18 May 2020, 15:44 last edited by
Thank you Bonnie.
I have found why Qt was not showing the icon!
I forgot to add the qico.dll plugin to my qt plugins directory. This is required.
1/3