Component.onCompleted doesn't seem to be called
Here's a minimal version of the code:
import QtQuick 2.0
import MuseScore 3.0
MuseScore {
menuPath: "Plugins.pluginName"
description: "Description goes here"
version: "1.0"
onRun: {
console.log("hello world")
Qt.quit()
}
Component.onCompleted: console.log("This will not be printed")
}
You'll see that the last line doesn't show in the log.
Am i missing something obvious, or is this a bug?
Comments
oh, and I tried putting this
Component.onCompleted
in builtin Qml components. It didn't work either.Documentation of
onCompleted
is here: https://doc.qt.io/qt-5/qml-qtqml-component.html#completed-signalYou don't see the log output from
onCompleted
because the framework creates the plugin first and only then attaches the slots that handle the call toconsole.log
The following plugin clearly shows that completed is run, as witnessed when uncommenting the marked line.
Also remember that "completed" in this case will mean whenever MuseScore loads the plugin (so at program startup for example); not whenever a user invokes it (that's what
onRun
is for).It works for QML constructs as well; see for example https://github.com/jeetee/MuseScore_Parsons_Code_Exporter/blob/master/P… where it is used to hide the File dialog upon creation so it only shows after a user presses the browse button.