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
Qt Code:
  1. ComboBox {
  2. id: combo
  3. editable: false
  4. model: ListModel {
  5. id: numoflines
  6. ListElement { text: "1"; color: "Black" }
  7. ListElement { text: "2"; color: "Black" }
  8. ListElement { text: "3"; color: "Black" }
  9. ListElement { text: "4"; color: "Black" }
  10. ListElement { text: "5"; color: "Black" }
  11. ListElement { text: "6"; color: "Black" }
  12. ListElement { text: "7"; color: "Black" }
  13. }
  14. onAccepted: {
  15. if (combo.find(currentText) === -1) {
  16. model.append({text: editText})
  17. currentIndex = combo.find(editText)
  18. }
  19. }
  20. onCurrentTextChanged: {
  21. Global.numoflines = parseInt(currentIndex) + 1;
  22. console.log(Global.numoflines);
  23. Qt.createComponent("Analysis.qml").createObject(parent), {x: 100, y: 200};
  24. }
  25. }
To copy to clipboard, switch view to plain text mode 


Analysis.qml:
Qt Code:
  1. Rectangle {
  2. id: base;
  3. x: 50;
  4. y: 480;
  5.  
  6. Column {
  7. spacing: -12;
  8.  
  9. Repeater {
  10. model: Global.numoflines;
  11. delegate: Rectangle {
  12. width: 800;
  13. height: 1;
  14. //color: "white";
  15. border { width: 1; color: "black" }
  16. radius: 3;
  17.  
  18. }
  19.  
  20. }
  21.  
  22. }
  23. }
To copy to clipboard, switch view to plain text mode