I have a Qt Quick QML file with a TextArea that I would like have display text from a QRC resource. Other controls with images have a source member that can be set to load directly from a QRC QURL (see here) but TextArea must set the text directly. What is the most concise way in Qt 5.x to set the text value from a QRC resource? I would like
TextArea
{
text: LoadResource("qrc://messages.txt")
}
Another question here alludes to a simple process but the code is gone and now only shows how to use do it in C++.
You can use
XMLHttpRequestto access local file and embedded resources but it requiresQML_XHR_ALLOW_FILE_READenvironment variable set to 1, e.g.Here's the
XMLHttpRequestcode snippet:You can Try it Online!