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. Application Icon not showing for Qt apps in Windows
Forum Updated to NodeBB v4.3 + New Features

Application Icon not showing for Qt apps in Windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • D Offline
    D Offline
    diecalt
    wrote on last edited by
    #1

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

    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.

    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.

    QCollidingMice with CMake

    Thank you

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by Bonnie
      #2

      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.

      1 Reply Last reply
      1
      • D Offline
        D Offline
        diecalt
        wrote on last edited by
        #3

        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 Reply Last reply
        1

        • Login

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