Adding SVG to resource with alias and referencing in QML
Solved
QML and Qt Quick
-
@SPlatten there is no magic to it.
right click on the sources in QtCreator -> copy path -> use as source in Image component
more important questions:
- Does your SVG follow "tiny 1.2" specifications?
- For what platform was it? IIRC for iOS there was no SVG support and it may not be the only one
-
@SPlatten said in Adding SVG to resource with alias and referencing in QML:
[Edit] When Copy Path or Copy URL ?
I did write path, didn't I?
The one starting with:
I see no
baseProfile="tiny"
in your xml code, so, it will probably not work -
@SPlatten soooo
first of, I would like to apologise, copy url is actually the correct one :Dsecondly, do use a "tiny" svg it will work:
//main.qml import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Window 2.15 import QtQuick.Layouts 1.15 Window { id: root width: 800 height: 600 visible: true Image{ id:img anchors.fill: parent source: "qrc:/SomeAliasedSVG.svg" } }
rsc.qrc <RCC> <qresource prefix="/"> <file>main.qml</file> <file alias="SomeAliasedSVG.svg">01_01.svg</file> </qresource> </RCC>
//svg file <?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" viewBox="0 0 30 30"> <desc>Example SVG file</desc> <rect x="10" y="10" width="10" height="10" fill="red"/> </svg>
works exactly as expected:
-
-
@SPlatten said in Adding SVG to resource with alias and referencing in QML:
Are they ?
They are relevant to have a compilable example...