Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Qt Quick Python] Resources is not a type while loading qml file from resources python file



  • Hello i had converted .qrc file into .py and imported it into launched file.
    When im loading icons it works but it does not work if i want to load .qml file to engine and always end up with "Resources is not a type" warning

    Here are my files:

    main.qrc:

    <RCC>
    <qresource>
        <file>sprits/utpim_bg1-1-1024x576.png</file>
        <file>sprits/icon.ico</file>
        <file>main.qml</file>
    </qresource>
    </RCC>
    

    main.py:

    import sys
    import res # Converted Resource file with Pyside2-rcc
    from PySide2.QtCore import QUrl
    from PySide2.QtGui import QIcon
    from PySide2.QtGui import QGuiApplication
    from PySide2.QtQml import QQmlApplicationEngine
    
    
    
    
    if __name__ == "__main__":
        app = QGuiApplication(sys.argv)
        app.setWindowIcon(QIcon(":/sprits/icon.ico"))
        engine = QQmlApplicationEngine()
        engine.load(QUrl("qrc:/main.qml"))
    
        if not engine.rootObjects():
            sys.exit(-1)
        sys.exit(app.exec_())
    

    The directory looks like:
    /ui
    sprits
    main.qrc
    main.qml
    main.py
    res.py
    /ui/sprits
    icon.ico
    ....


Log in to reply