Stepping Through Segments
I am using this code to try to inspect segments of a score:
onRun: {
var cursor = curScore.newCursor();
cursor.rewind(0);
while(cursor.segment) {
console.log(cursor.segment.segmentType);
cursor.next();
}
Qt.quit()
}
}
But it tells me that every segment is of type ChordRest.
Why am I missing all the other segment types, like TimeSig, Clef, etc. ?
Comments
Because the default .filter for a cursor is set to ChordRest
In reply to Because the default .filter… by jeetee
Is there a way of stepping through with a different filter?
In reply to Is there a way of stepping… by yonah_ag
Yes, see the example at https://musescore.org/en/node/329791#comment-1117448
The other option is to not use Cursor at all, but just follow the raw segments themselves, like walk.qml does it.
In reply to Yes, see the example at… by jeetee
Many thanks. These are both really helpful and will each be useful in different contexts.