How to avoid repetitive code in QML?
问题 I'm using Qt 5.4.1. I'm currently setting up some buttons in QML. I want similar state behaviours for some of the buttons - how to do I avoid having large chunks of very similar code repeated through the QML? Rectangle { id: songFilterButton x: 0; width: 80 y: 0; height: 60 Text { anchors.centerIn: parent text: "Songs" } state: "on"; states: [ State { name: "on" PropertyChanges{ target: songFilterButton; color: "steelblue" } }, State { name: "on" PropertyChanges{ target: songFilterButton;