LKBEN11635: How to add a resource to your qt application with Qt Creator.
Symptom
You need to add a resource to your application.
Cause
Resources can be used to store png files for e.g. icons.
Solution
I will describe one way of doing it, there are more than one possibility to add resources to your project.
When I add icons to my application, I create a folder called "Images" into my project directory. I open my project. make a right click on the project and select "Add..." (in German: Hinzufügen). From "Files and Classes you select "Qt" and "Qt Recource File".
Click "Choose" and give it a meaningfull name.Now you give the resource a prefix and add files to it. You can add all your icon files at once if you use a multi selection.
To use the resource you enter the name from the prefix and the path to the resource.In this case it would look like:
w.setWindowIcon(QIcon(":/Prefix/Images/iconname.png"));
Have fun.
Disclaimer:
The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!About the Author
Author:
- Keskon GmbH & Co. KGWim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.
Latest update: 16/01/2023