Important: Please read the Qt Code of Conduct -

Application Icon not showing for Qt apps in Windows

  • 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:

    Using 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.

    wcex.cbSize = sizeof(WNDCLASSEX);          = 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.

    QCollidingMice with CMake

    Thank you

  • 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.

  • 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.

Log in to reply