To add image resources I now do this:
1. Create a new resource file by clicking File -> New File or Project and then Choose Qt resource file.
2. Add a prefix for example /icons
3. Add your images files for example: images/icon.png (with a images a subdirectory in your project folder
4. Refer to these resources in your code as ":/icons/images/icon.png"
The changed point compared to the resource file example in the book is the prefix. You now have to add a prefix which (probably) did not exist in the past. In the example application (called "application") that comes with QtCreator the prefix that is used is simply "/".
Adding the icon to a widget (e.g. your main window) is now simple:
setWindowIcon(QIcon(":/icons/images/icon.png"));And as requested some screen shots.
Step 1, creating a new resource file:
Step 2, add a prefix:
Simply type over the default prefix label generator by QtCreator. Your prefix will appear in the main window:
Step 3, add image files (after selecting the prefix in the main window):
The final result then looks something like this:
Thank you, it is good. Useful. But better with screenshot.
ReplyDeletethank you
ReplyDeletethank u so much
ReplyDeleteThanks a lot!
ReplyDeletethanks it's work for me to , I'm in qt 5.12.1
ReplyDeleteWhen you get the last documents ensure you have the accompanying data:logo design service
ReplyDeleteThank you so much
ReplyDelete