Running QML scripts
I'm trying to run a QML plugin in MuseScore 4.5.1 (Windows 10, 64-bit) to insert layout breaks after rests in a score. The plugin shows up in the menu and is enabled, but it has no visible effect on the score, and console.log() output does not appear, even when running MuseScore from a terminal.
I confirmed:
The plugins are in the folder shown in Preferences > General > Folders
They appear in Plugins > Plugin Manager, and I can enable them and run them from the menu
I tried multiple plugins: one that adds staff text to each segment, and one that adds a layout break after rests — none had any effect
I am importing scores via MusicXML and saving as .mscz
I experimented with QML on advice from chatGPT - and the bot wrote this topic after our tests. One other wrinkle. The computer is using OneDrive.
Thanks in advance
Attachment | Size |
---|---|
PROVERBS-004.XML | 166.48 KB |
lineBreaksAfterRests.qml | 856 bytes |
testHello.qml | 202 bytes |
testVisible.qml | 646 bytes |
Comments
Did you check the logs?
In reply to Did you check the logs? by Jojo-Schmitz
for a start,
import MuseScore 3.0 (not 4.0)
Qt.quit() must be just quit() for MS4
In reply to for a start, import… by graffesmusic
The former would surely have shown in the logs, the latter would cause MuseSore to crash, if the plugin would have run at all
In reply to for a start, import… by graffesmusic
And as of MuseScore 4.4 you can even drop the version number on import of modules
Couldn't find any way to check the logs.
imported 3.0 and removed qt. reloaded scripts and still no action on the xml or the saved mscz
Thanks for the tries. It would save me 1000s of clicks if I find a way to do this. I tried putting line breaks into my XML but they didn't load.
In reply to Couldn't find any way to… by Bob MacDonald1
Check the logs, you'll find them in
%LOCALAPPDATA%\MuseScore\MuseScore4\
In reply to Check the logs, you'd find… by Jojo-Schmitz
I found the logs -- thanks. The current error message is "Property 'newLayoutBreak' of object mu::engraving::apiv1::Score(0x1f953591ff0) is not a function"
Where would I find info on how to interpret this -- and how to find a function that will do what I want to do.
Thanks for your patience.
In reply to I found the logs -- thanks… by Bob MacDonald1
The only instance of the string "newLayoutBreak" in your code is in line 27:
> const layoutBreak = curScore.newLayoutBreak();
I don't know QML well enough to know for sure, but I suspect that "new" is the problem. It needs either to go elsewhere in the statement, to be separated in some fashion from other parts of the statement, or to be removed altogether. Purest WAG, yes! :-)
In reply to The only instance of the… by TheHutch
You can't just take a C++ method and use it in QML, you'd need to use whatever is exposed to the Plugin API
In reply to You can't just take a C++… by Jojo-Schmitz
Ha! I'll tell chatGPT! Where do I find what is exposed to the plugin API? I found some instructions here: https://musescore.org/en/plugin-development. Seems that there is no function that would insert a break.
I will plug on by hand -- it is hard on the eyes but good for the reading practice
Thanks again Jo-jo
In reply to Ha! I'll tell chatGPT! Where… by Bob MacDonald1
You're using ChatGPT to write code? *LOL* Almost certain to be incorrect, and often in the most subtle of ways.
Post a question in the Plugins sub-forum (https://musescore.org/en/forum/443). That's where all the serious plug-in coders hang out.
In reply to Ha! I'll tell chatGPT! Where… by Bob MacDonald1
That's the API for MuseScore 1.x
In reply to Ha! I'll tell chatGPT! Where… by Bob MacDonald1
Check https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/annot… which is for MuseScore 3.x, but largely should apply to 4.x too
There's
new LayoutBreak()