lost in QML documentation

• Feb 11, 2024 - 09:50

Hello all
still trying to write QML scripts but some features details evade me.
where to look in documentation... that is the question?
I try to browse the MuseScore_PluginAPI_Docs on github but finding some properties may be hard (moreover I am french and don't understand some words)
examples:
- I want the Lyrics I created be underscore
var text = newElement(Element.LYRICS) ;
text.setProperty(FontStyle.UnderLine) ; //???? NO
Does not work - for sure this was just a guess!)
- I would like to know if a note is a "prolongation" of a preceding note (is the notion to be translated "Tie" I just don't know)
So if you can tell me what could be the best way to browse the doc for QML programming -> thanx a lot!


Comments

let's have a look at the doc and why it is confusing:
from class Lyrics: setProperty (Pid propertyId, const QVariant &)
ok fine but how do I find the proper arguments?
(I have tried various properties such as StyledProperty.lyricsEvenFontStyle but that's a guess and it does not work same thing for the named QVariant such as FontStyle.UnderLine )
so the problem is more : how to read the github doc with mysterious references to objects, id and so on ?

well again I fear I can't browse correctly the doc 😞 !
here is an example of something I don't understand:

import QtQuick 2.9
import MuseScore 3.0
/// some code

var staves = curScore.staves ;

Then I get this :

Warning: QMetaProperty::read: Unable to handle unregistered datatype 'QQmlListProperty' for property 'Ms::PluginAPI::Score::staves'

????????????😣😣😣

In reply to by sittingBugle

Hi sittingBugle,

> finding some properties may be hard

TLDR;

Yes, it is normal to feel lost. It is not your problem though, it is that the mysterious doxygen website is written in a way, which requires quite a lot of C++ , javascript and QML (paradoxically) coding experience and luck guesses to fully understand. To improve the situation, we need more manpower to do editing work.

The "attributes", "functions" etc listed on the doxygen website are information automatically extracted from the Musescore Core C++ code files. Some of them may not be available in (exposed to) QML scripting.

It'd be useful to read a list of each classes' "attributes", "functions" that are exposed to QML scripting feature, unfortunately such a list does not exist yet, please feel free to contribute.

I keep on yakking:

The Musescore (C++) is online-community based volunteer project, it is in perpetual continuous development, so the C++ codes improve and change frequently. A few developers (in fact, maybe mainly one man's work, dmitrio95 I don't really know the history) volunteered to work on the QML plugin scripting feature. He/they chose a limited and most useful selections of "attributes" and "functions" of each class from the perpetually changing code files, and then exposed them to QML scripting feature. They fixed bugs and maintained the code. They also spared time generously and wrote down key points in doxygen website so that we could write QML plugins. It may be helpful to think of these documents as pieces of notes written down by genius coders in a haste. All genuis confuses.

When I'm not sure, I check the code on github.

  • Musescore codebase is on github, which is currently version 4. Search result force returns version 4 files.
  • An archived searchable version 3.6.2 codebase is at https://github.com/fp22june/MuseScoreTag362
  • In 3.6.2, files under folders such as "libmscore" are C++ main codes, contents inside may not be exposed to QML
  • In 3.6.2, the code files that expose content to QML scripting feature are under "mscore/plugin/api"

Doxygen website shows content automatically created from C++ code files, hence the confusion. (Not sure) To add to the confusion, QML scripting info on it are for Musescore 3.5.

> Does not work ... best way to browse

I also use the method suggested by elsewhere - learn from others' code. It seems faster than digging into the doxygen website. Also, do you know Developers' handbook > Plugin development > Plugins for 3.x page? Especially the snippets?

> text.setProperty(FontStyle.UnderLine)

please try text.fontStyle=4

(Not sure) setProperty and FontStyle enums may not be exposed to QML, see doxygen list of available enum.
To get all the valid, available "attributes", "functions" etc of an object on a score, and to get the number 4, see the debugger tool, Object Explorer plugin etc on https://musescore.org/en/handbook/developers-handbook/plugins-3x#learnm…

> from class Lyrics: setProperty (Pid propertyId, const QVariant &) ok fine but how do I find the proper arguments?

(Not sure) setProperty and PID not exposed.

> Warning: QMetaProperty::read: Unable ...

I'm pretty sure error is not from the line "var staves = curScore.staves ;" mind sharing more?

In reply to by msfp

thanks msfp I am getting old and so practice quick and (very) dirty programming...
but I am pretty sure of the error on staves.
(I have been browsing the internet for solutions and just found strange macros - I hate macros - that are just rejected by the syntactic analyzer)

In reply to by sittingBugle

LOL very dirty.
Yes, you are correct about the erro. I just tested inside the 3.6.2 plugin creator, the following code creates error message. Also, after searching https://doc.qt.io/archives/qt-5.9/search-results.html?q=QQmlListProperty I suspect it is due to a bug on the C++ side, if that's the case there's nothing we can do about the warning in QML plugin scripting. I don't have knowledge about macros and syntactic analyzer, I know very little about C++ too.

cpp.PNG
My previous comment is wrongly based on 3.6.2 unstable build.

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