Splitting a plugin into two qml files or more

• Dec 5, 2019 - 20:37

For readability reasons, I want to move a part of the plugin into another qml file. Is there an #include or a similar directive?


I believe it should be possible to use import myotherfile.js, but I'm not sure how the relative path would be resolved.

Basically, you should be able to do one of the following:

  • Extract some QML component into a separate .qml file and use that component in the "main" .qml file just by its name. If that separate .qml file is in the same directory that the QML file which uses it then no import statements are required at all. See the SquareButton example in Qt documentation.
  • Extract some functions to a separate .js file (say, utils.js) and put an import statement to the beginning of the file like
    import "utils.js" as Utils
    After that you should be able to use it in your QML file as
    var a = Utils.someFunction(b, c);

In reply to by dmitrio95

I have a plugin that imports other files. When I make changes to those (I use VSCode) and then click update in Musescore's "Plugin Creator", those files are not updated as it seems... any chance to implement that, too?

EDIT: I just realized that I can delete the cached version (*.qmlc) of external files, but that doesn't do it either.

Do you still have an unanswered question? Please log in first to post your question.