import QtQuick 2.0 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 /// USE_WINDOW import MuseScore 1.0 MuseScore { version: "2.0" description: qsTr("To test ComboBox working") menuPath: "Plugins.Test Combo" //pluginType: "dialog" // // The UI // /// USE_WINDOW Window { id: window visible: true modality: Qt.ApplicationModal // behave like a dialog color: "lightgrey" property int wdgMargin: 8 property int wndWidth: 300 property int wndHeight: 200 width: wndWidth; height: wndHeight; /// USE_WINDOW // center on screen x: Screen.width / 2 - width / 2 y: Screen.height / 2 - height / 2 RowLayout { id: rowSelect anchors.top: window.top anchors.left: window.left anchors.right: window.right anchors.margins: window.wdgMargin spacing: window.wdgMargin Label { id: label text: qsTr("Combo:") Layout.alignment: Qt.AlignVCenter } ComboBox { id: combo Layout.fillWidth: true model: ListModel { id: listModel } } /// USE_WINDOW } } // // Components and Methods // onRun: { init(); } //------------------------------------------------------------------- // init() // initializes the combo box. Called by main object's onRun(). //------------------------------------------------------------------- function init() { var i; var names = []; // fill the combo box // combo.textRole = "text"; // does anything at all? for (i = 0; i < 5; i++) names[i] = { "text": "Name " + i }; listModel.append(names); // some diagnostics console.log("Combo text role: " + combo.textRole); console.log("Num. of names in list model: " + listModel.count); var model = combo.model; console.log("Model: " + model); for (i = 0; i < combo.count; i++) console.log("Name " + i + ": " + model.get(i).text); } } // plugin end