How to create qrc file(qml) in Python Qt(PyQt)

1. create qml file 
 - main.qml 
 - test.qml


2. create resource.qrc file
resource.qml code

-----------------------------------

<RCC>

<qresource>

    <file>qml/main.qml</file>

    <file>qml/test.qml</file>

</qresource>

</RCC>
-----------------------------------


3. execute command in terminal (in workspace included qml files)
 $ pyside2-rcc -o resource.py resource.qrc


4. check resource.py file 
 : 
Completed when the resource.py file is created.

 

 

How to use qrc file!

1. in main.py 

ex ) qrc:///filename

QUrl("qrc:///qml/test.qml")

 

2. in main.qml file

ex ) qrc:/qml/test.qml

source: "qrc:/qml/test.qml"


#qrc #resource.qrc #resource.py #python #qt #pyqt #pyside2-rcc


No comments:

Post a Comment

Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore!

 🏙️ Apartment Buying Guide 2025: Shocking Red Flags You Should NEVER Ignore! 🚨 Are you thinking about buying an apartment in 2025? 🏢  It’...