How to deselect the current segment in QML

• Sep 10, 2016 - 03:28

I have a QML script that sets the bottom x notes in a vertical stack of a selected region to not be selected within the current selected segment:

notes[i].selected = false;

See screen shot for the result...if one were to do this manually, one would have to click each of those notes to toggle their selection status to false.

My QML script ends there but at that point if I attempt to delete the selected region (CTRL+X) MuseSore will simply delete the entire selected segment without regard to the note.selected status.

Anyone see a workaround for this?

My goal of course is to have a QML script/plugin that can de-select the bottom x notes of a vertical stack so that I can then (in MuseScore) simply cut the top note out.

I'm familiar with Explode/Implode of course, but they are not exactly what I'm looking to do here...

Thanks for any insight!


Looking at the screenshot you can see the stems and all accidentals are still highlighted in blue as well. I think that the chords themselves are still considered selected, and deleting them will delete all of their children as well.

I'm wondering if the opposite approach would work better? First getting start and endpoint of the selection, then deselecting everything, and then reselecting your top notes.

In reply to by jeetee

Thanks for your reply and suggestion! Your reply seem to correlate with how the applications code, specifically the Inspector's code selects only Notes - and the current C++ for this in the repo is something like this:…

void InspectorGroupElement::notesClicked()
Score* score = inspector->el().front()->score();
QList el = score->selection().elements();
QList nel;
for (Element* e : el) {
if (e->isNote()) {
Note* note = toNote(e);
//if note is not grace note, then add to selection
if (!note->chord()->isGrace()) {

I'd like to do something similar to this in QML - only rather than select all the notes, I'd like to select only specific notes within a vertical stack and then de-select the cursor selection region so that only my selected notes remain. At that point, anyone could perform actions on those selected notes (e.g., cut, move to another layer, etc.)

So the root of my question comes down to if it's possible to set the score's current selection segment to nothing from within QML...?


In reply to by stevel05

Ah, thanks for the tip! I wasn't familiar with that call...from what I can tell it does indeed deselect the selected region...seems also to de-select any notes in a chord that are selected...

Is there any documentation on what other "cmd" function options there are? Not finding anything in the "help" on this.

In reply to by rob@birdwellmu…

Just to be clear: cmd("escape") does not mean "clear the selection"; it means, do whatever would've happened if the user pressed the Esc key on his/her keyboard.

It just so happens that when having something selected, this results in clearing the selection. But if you -for example- were in edit text mode, it would simply cancel out of editing text mode.

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