Adding SVG to resource with alias and referencing in QML
- 
@JoeCFD , I decided to create a simple application to experiment with the resources. I used the same SVG file. The resource file: <RCC> <qresource prefix="/"> <file alias="stale.svg">stale.svg</file> <file>mainWindow.qml</file> </qresource> </RCC>In the mainwindow: void MainWindow::paintEvent(QPaintEvent *pobjEvt) { Q_UNUSED(pobjEvt); QPainter objPainter(this); QImage* pobjImage(new QImage(":/stale.svg")); bool blnIsNull(pobjImage->isNull()); qDebug() << QString("Image isNull: %1").arg(((blnIsNull == true) ? "Yes" : "No")); objPainter.drawImage(10, 10, *pobjImage); }This works absolutely fine and the iamge is displayed correctly. I will not try to use this to figure out why the original isn't working. 
- 
@SPlatten said in Adding SVG to resource with alias and referencing in QML: staleiIcon.svg You have a typo in the file name? 
- 
@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 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 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 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 it's not really compile able, is it ? 
 I don't have your *pro, nor your main.cpp file, nor the folder structure you claim to have.also giving your Image a width and height does help, because its super tiny without it  
- 
@SPlatten said in Adding SVG to resource with alias and referencing in QML: Are they ? They are relevant to have a compilable example... 
- 
@SPlatten said in Adding SVG to resource with alias and referencing in QML: Are they ? They are relevant to have a compilable example... 
 

