Important: Please read the Qt Code of Conduct -

Changing the content of qmldir at runtime

  • Hi Guys,

    I have a problem with qmldir in qrc. I Created a resource file(qrc) for my project; in this file I add all the qml files and qmldir into it. My problem is : I have to specify the absolute paths to the location of Qml plugin I wrote in qmldir . If It's on my computer; it's easy. But if It's on another computer, I need to modify the paths of qmldir. Is there any ways to change the content of qmldir file when It's embedded into resource file ?

    Thank you!

  • Qt Champions 2017

    Not sure why you need absolute path. Did you try something like this ?

    import QtQuick 2.2;
    import 'qrc:/pthinks/qmlmodules/';
    import 'qrc:/pthinks/maths/factorial.js' as fact;

    Here qmldir is under qmlmodules path.

  • Because I embedded all qml files into qrc; so, if I want QML files in qrc import my plugins I also need to add qmldir into qrc. The problem is : qmldir in qrc can not understand the relative path, it only know the absolute path to my plugin . I also use QQmlEngine::addPluginPath() to add the location of plugin for engine . But the engine can not recognize plugins so I need to add absolute paths to qmldir

  • Qt Champions 2017

    qmldir can contain the relative path from the directory where this qml files exist.

    <TypeName> <Version> <File>

    Here is file can be relative path from the directory where qmldir exist.

  • Hello,

    If I don't add qmldir into qrc; the relative path is ok. For ex: ../Plugin.
    But if I add qmlfir into qrc, QmlEngine can't understand the current path to specify the location of Plugin, so I need to use the absolute path: /home/myname/plugin .

    Do you have other solution ?


Log in to reply