I've been trying to get a custom icon I created to display in the top left corner of a Qt application I've been writing, and no matter what I try, I cannot get it to display. It will only display the default icon no matter what I do. I created a test app to try and just get it to work without doing it in my app, but even that won't work.
I can get it to display the same icon within a window with QPixmap, so it's not a path issue.

I've even tried deleting the Makefile created by qmake and the .qmake.stash files and running

Qt Code:
  1. qmake test_icon.pro
To copy to clipboard, switch view to plain text mode 

again. But it still will not display my icon no matter what I try.

I would like to display the same icon in all windows of my Qt app, as well as the taskbar icon as well.

I'm new to programming with Qt, so I have no idea what I'm doing wrong.

I'm using Manjaro Linux with Qt5.

My main.cpp file:

Qt Code:
  1. #include <QApplication>
  2. #include <QMainWindow>
  3. #include <QIcon>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication app(argc, argv);
  8.  
  9. // Set the application icon using the resource path (:/myicon.png)
  10. app.setWindowIcon(QIcon(":/myicon.png"));
  11.  
  12. // Create main window (and any other windows)
  13. QMainWindow mainWindow;
  14. mainWindow.setWindowTitle("My App");
  15. mainWindow.show();
  16.  
  17. // Any other top-level windows you create will automatically use this icon
  18. // unless you set a different icon on them individually using setWindowIcon()
  19. // on the widget instance itself.
  20.  
  21. return app.exec();
  22. }
To copy to clipboard, switch view to plain text mode 

My resources.qrc file:

Qt Code:
  1. <!DOCTYPE RCC>
  2. <RCC version="1.0">
  3. <qresource prefix="/">
  4. <file>myicon.png</file>
  5. </qresource>
  6. </RCC>
To copy to clipboard, switch view to plain text mode 

My test_icon.pro file:

Qt Code:
  1. ######################################################################
  2. # Automatically generated by qmake (3.1) Fri Jan 16 16:35:33 2026
  3. ######################################################################
  4.  
  5. TEMPLATE = app
  6. TARGET = test_icon
  7. QT += widgets
  8. INCLUDEPATH += .
  9. RESOURCES += resources.qrc
  10.  
  11. # You can make your code fail to compile if you use deprecated APIs.
  12. # In order to do so, uncomment the following line.
  13. # Please consult the documentation of the deprecated API in order to know
  14. # how to port your code away from it.
  15. # You can also select to disable deprecated APIs only up to a certain version of Qt.
  16. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
  17.  
  18. # Input
  19. SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode 

What in the f**king hell am I missing?? I don't understand what I'm doing wrong. I'm at my wits end with this.

Can someone please tell me what I'm doing wrong in plain simple english?

Thanks in advance for any help.