Onclicked

• Mar 1, 2023 - 22:19

Hi guys
I just want to created a simple app where pressing button "create"will just add a note of a pitch o 70 to a score.

I tried doing what I attached but it doesnt work

Can anyone help

import QtQuick 2.1
import MuseScore 3.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0

MuseScore {
version: "3.0"
description: "Create random score."
menuPath: "Plugins.random2"
requiresScore: false
pluginType: "dock"
dockArea: "left"
width: 150
height: 75

  onRun: { 

}

function addnote(){
var cursor = curScore.newCursor(); // Make a cursor object.
cursor.rewind(0);
cursor.addNote(70);

}



GridLayout {
    anchors.fill: parent
    columns: 2
    rowSpacing: 5


    Text {
        text: "Octaves"
        color: "white"
        }



    SpinBox {
        id: octaves
        minimumValue: 1
        maximumValue: 3
        stepSize:     1
        Layout.fillWidth: true
        Layout.preferredHeight: 25
        value: 1
        }

    Button {
        text: "create"
        Layout.columnSpan: 2
        Layout.fillWidth: true
        onClicked: {
         addnote()
            }
        }
    }
}

Comments

the note is added but you need to update the view :
curScore.endCmd()
eg right after cursor.addNote(70)

to make things undo-able run this before all modifications:
curScore.startCmd()

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