qml Loader local qml file access to qrc component
-
Hello,
I'm writing qml application. Default main page is here:Window { Item { id: mainItem Loader { id:pageLoader anchors.fill: parent source: "file:///"+applicationDirPath+"/Pages/"+"Test.qml" } } }
I have component ImageLCD.qml in qrc:
Image { property string sourceLocal source: "file:///"+applicationDirPath+"/Img/"+sourceLocal }
Finaly I have TestQRC.qml in qrc:
Rectangle { color:"green" ImageLCD{ width: 150 height: 150 sourceLocal: "knife.png" }//*/ }
And I have same code in Test.qml file in ** local** directory "Pages" .
When pageLoader load qrc file (TestQRC.qml") all working good.
But When I load local qml file with same code - I got error:ImageLCD is not a type
I need load local qml file and I need to use own components defined in QRC system. How to do this?
Thank you
-
Hello,
I'm writing qml application. Default main page is here:Window { Item { id: mainItem Loader { id:pageLoader anchors.fill: parent source: "file:///"+applicationDirPath+"/Pages/"+"Test.qml" } } }
I have component ImageLCD.qml in qrc:
Image { property string sourceLocal source: "file:///"+applicationDirPath+"/Img/"+sourceLocal }
Finaly I have TestQRC.qml in qrc:
Rectangle { color:"green" ImageLCD{ width: 150 height: 150 sourceLocal: "knife.png" }//*/ }
And I have same code in Test.qml file in ** local** directory "Pages" .
When pageLoader load qrc file (TestQRC.qml") all working good.
But When I load local qml file with same code - I got error:ImageLCD is not a type
I need load local qml file and I need to use own components defined in QRC system. How to do this?
Thank you
-
@poucz
similar like here
https://doc.qt.io/qt-6/resources.htmlcreate a qml.qrc file:
<RCC> <qresource prefix="/"> <file>qml/main.qml</file> <file>qml/MainToolBar.qml</file> <file>qml/ControlPanel.qml</file> <file>qml/MainScreen.qml</file> <file alias="qml/CentralLogo.qml">qml/splash/CentralLogo.qml</file> <file alias="qml/SplashScreen.qml">qml/splash/SplashScreen.qml</file> </qresource> </RCC>
-
J JoeCFD referenced this topic on