Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Reading strings for labels from .qrc
There does not seem to be an obvious answer here so I submit this for the forum.
I wish to load the English text for labels from a .qrc file in a similar way as Windows uses rcc files in VB. However, there is no clear indication in the docs as to how to do this. You can store a file name in the .qrc that can then read in text from the file (using the URL name). But, that is not the same.
How do you store label text in a .qrc then use that text for a label ( e.g. label.setText(tr(<loaded text>) ).
The resource creator only seems to allow file names. Seems like a newbie question but there it is.
Are you thinking about translating your application ?
Yes that is a possibility using tr().
Then have a look at the Qt Linguist Manual, it explains how to translate Qt applications
This thread is not about translation or i18.
qrc is only there to embed files in your application
Then what is the point. I mean, the file URL could be included in the source as constant strings without the need for the .qrc at all. QImage, QIcon, and QPixmap all allow use of the url() idiom.
If all it does is load file names what is the point?
No that's not all, the goal of the qrc is to build these file directly in your application.
Have a look at the "resources":http://qt-project.org/doc/qt-5.0/qtcore/resources.html documentation.
dbzhang800 last edited by
Hi, take a look at the rcc generated files qrc_xxxx.cpp, you can find all the magic behind the .qrc file.
[quote author="ad5xj" date="1375134174"]Then what is the point. I mean, the file URL could be included in the source as constant strings without the need for the .qrc at all. QImage, QIcon, and QPixmap all allow use of the url() idiom.
If all it does is load file names what is the point?[/quote]