This is the code to repeatedly dray lines on increasing the value on a ComboBox. But how can I delete the number of lines on decreasing this value?
main.qml
ComboBox {
id: combo
editable: false
model: ListModel {
id: numoflines
ListElement { text: "1"; color: "Black" }
ListElement { text: "2"; color: "Black" }
ListElement { text: "3"; color: "Black" }
ListElement { text: "4"; color: "Black" }
ListElement { text: "5"; color: "Black" }
ListElement { text: "6"; color: "Black" }
ListElement { text: "7"; color: "Black" }
}
onAccepted: {
if (combo.find(currentText) === -1) {
model.append({text: editText})
currentIndex = combo.find(editText)
}
}
onCurrentTextChanged: {
Global.numoflines = parseInt(currentIndex) + 1;
console.log(Global.numoflines);
Qt.createComponent("Analysis.qml").createObject(parent), {x: 100, y: 200};
}
}
ComboBox {
id: combo
editable: false
model: ListModel {
id: numoflines
ListElement { text: "1"; color: "Black" }
ListElement { text: "2"; color: "Black" }
ListElement { text: "3"; color: "Black" }
ListElement { text: "4"; color: "Black" }
ListElement { text: "5"; color: "Black" }
ListElement { text: "6"; color: "Black" }
ListElement { text: "7"; color: "Black" }
}
onAccepted: {
if (combo.find(currentText) === -1) {
model.append({text: editText})
currentIndex = combo.find(editText)
}
}
onCurrentTextChanged: {
Global.numoflines = parseInt(currentIndex) + 1;
console.log(Global.numoflines);
Qt.createComponent("Analysis.qml").createObject(parent), {x: 100, y: 200};
}
}
To copy to clipboard, switch view to plain text mode
Analysis.qml:
Rectangle {
id: base;
x: 50;
y: 480;
Column {
spacing: -12;
Repeater {
model: Global.numoflines;
delegate: Rectangle {
width: 800;
height: 1;
//color: "white";
border { width: 1; color: "black" }
radius: 3;
}
}
}
}
Rectangle {
id: base;
x: 50;
y: 480;
Column {
spacing: -12;
Repeater {
model: Global.numoflines;
delegate: Rectangle {
width: 800;
height: 1;
//color: "white";
border { width: 1; color: "black" }
radius: 3;
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks