Using QT .qrc File with Visual Studio Proj…?
-
I have a Visual Studio 2017 project that is built with QT and VTK using CMake. I need to use image resources, and wish to use QT's .qrc resource system.
Information on this seems rare and complex when not using a QT project file. I have found this:
- Create a .qrc file that contains a list of the resources you would like to include
- Create a custom build step that invokes rcc on that file (documentation)
- Compile and link the resulting cpp source file into your program.
https://stackoverflow.com/questions/56035630/how-to-use-qt-resource-files-in-visual-studio-without-a-qt-project
I am just completely confused right now on what the proper way to go about this is, and this is not enough information.
-
@AlexanderAlexander said in Using QT .qrc File with Visual Studio Proj…?:
Do you know how to add a resource file in QT Creator's Designer
No, simply use Qt-Designer, add it there and then it's also available in QtCreator
-
Simply add the qrc file to your sources with the help of QT5_ADD_RESOURCES cmake macro
-
@Christian-Ehrlicher Do I also need to add this to my add_executable in my CMake file (Note: I have Auto RCC on)?
-
If you've autorcc on then you don't need the macro: https://cmake.org/cmake/help/latest/manual/cmake-qt.7.html#autorcc
-
@Christian-Ehrlicher I have built my proj with my new CMake file, and have added my icons images to the qrc file. Within MSCV2017, my QT Addin seems to be working, and I used it to add the resources to the file. Upon building the proj and opening up the solution, I see a qrc_.cpp file generated, and that my images are "in" it (its very complex to me). The only problem is that when I open my UI file with QT Designer, and go to change button icons, nothing is in the resource browser.
-
@Christian-Ehrlicher I have built my proj with my new CMake file, and have added my icons images to the qrc file. Within MSCV2017, my QT Addin seems to be working, and I used it to add the resources to the file. Upon building the proj and opening up the solution, I see a qrc_.cpp file generated, and that my images are "in" it (its very complex to me). The only problem is that when I open my UI file with QT Designer, and go to change button icons, nothing is in the resource browser.
You have to add the resource file to your ui file in the designer - the designer and cmake are two completely different things which don't know of each other so the designer also can't know that you added a qrc file to CMakeLists.txt
-
You have to add the resource file to your ui file in the designer - the designer and cmake are two completely different things which don't know of each other so the designer also can't know that you added a qrc file to CMakeLists.txt
@Christian-Ehrlicher
Hi
like this
https://doc.qt.io/qt-5/designer-resources.html
`?
Or is it different when from Visual Studio IDE ? -
@Christian-Ehrlicher
Hi
like this
https://doc.qt.io/qt-5/designer-resources.html
`?
Or is it different when from Visual Studio IDE ?@Christian-Ehrlicher To clarify, I am in QT Creator's embedded Design mode. How would I add the resource file from there, the only thing to do with resources that I can open is when I edit the icon property of an item. It just opens up the "Choose Resource" Window, and there is just <resource root>. I cant edit a pathway or add a file...?
-
@AlexanderAlexander said in Using QT .qrc File with Visual Studio Proj…?:
I am in QT Creator's embedded Design mode
Previously your said you're using MSVC2017 + Qt Vs Addin and using Qt designer
Within MSCV2017, my QT Addin seems to be working ... I open my UI file with QT Designer
In Qt designer you can add a resource file in the resource editor dock widget.
-
@AlexanderAlexander said in Using QT .qrc File with Visual Studio Proj…?:
I am in QT Creator's embedded Design mode
Previously your said you're using MSVC2017 + Qt Vs Addin and using Qt designer
Within MSCV2017, my QT Addin seems to be working ... I open my UI file with QT Designer
In Qt designer you can add a resource file in the resource editor dock widget.
@Christian-Ehrlicher My apologies for the confusion, I always call it that by accident. Do you know how to add a resource file in QT Creator's Designer. I can't find any documentation on how to do so...
-
@AlexanderAlexander said in Using QT .qrc File with Visual Studio Proj…?:
Do you know how to add a resource file in QT Creator's Designer
No, simply use Qt-Designer, add it there and then it's also available in QtCreator
-
@AlexanderAlexander said in Using QT .qrc File with Visual Studio Proj…?:
Do you know how to add a resource file in QT Creator's Designer
No, simply use Qt-Designer, add it there and then it's also available in QtCreator
@Christian-Ehrlicher I can't believe I never thought of doing that. It's finally working now. Thank you so much for the help and sorry about all of my confusion.