Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No resource file in Qt Creator

I am using Qt Creator and I have created a resource file. When I try to access the resource file when I am in designer mode, it says that resource root is empty.

How can I specify the resource dir? How come it does not appear if it is in the same folder?

like image 738
Sara Avatar asked Nov 14 '22 05:11

Sara


1 Answers

For using resource file even if it is situated in the same folder, you have to add the resource file to the project in Qtcreator for using it. Just right click on the project name on the tree view of your project in QtCreator and click on add existing files, then you add your resource file and now you can use your resource in your project.

By adding it this way, it will be added to you project. Or you can register resources to project explicitly with

 QResource::registerResource("/path/yourresource.rcc");

You can specify resource directory using :/ prefix or qrc:///.

For ex:qrc:///files/yourfile will get you to the yourfile situated in files in your added resource.

like image 60
ScarCode Avatar answered Jan 30 '23 19:01

ScarCode