Last active
          December 26, 2015 19:59 
        
      - 
      
- 
        Save stdk/7205749 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import QtQuick 1.1 | |
| ListView { | |
| function set_items(items) { | |
| for(var i=0; i<items.length;i++) { | |
| model.append({ name: items[i], number: i, explanation: ''}) | |
| } | |
| } | |
| signal action | |
| id: widget | |
| anchors.fill: parent | |
| width: 700 | |
| height: 300 | |
| model: ListModel { | |
| id: model | |
| } | |
| focus: true | |
| property variant ticket | |
| onTicketChanged: { | |
| for(var i=0; i<model.count; i++) { | |
| var item = model.get(i) | |
| var payment = ticket.pay(item.name) | |
| model.setProperty(i, 'explanation', payment.explanation) | |
| } | |
| } | |
| onCurrentIndexChanged: { | |
| var element = model.get(currentIndex) | |
| model.setProperty(currentIndex, 'number', element.number + 1) | |
| } | |
| highlightMoveDuration: 500 | |
| highlightFollowsCurrentItem: true | |
| highlight: Rectangle { | |
| color: "lightsteelblue" | |
| radius: widget.currentItem.radius | |
| } | |
| delegate: Rectangle { | |
| id: rect | |
| height: parent.height | |
| width: text.width + 50 | |
| radius: 25 | |
| color: "transparent" | |
| MouseArea { | |
| anchors.fill: parent | |
| onClicked: { | |
| widget.currentIndex = index | |
| widget.action() | |
| } | |
| } | |
| border.color: "black" | |
| border.width: 1 | |
| Text { | |
| id: text | |
| text: name + ': ' + number | |
| font.pointSize: 18 | |
| anchors.horizontalCenter: parent.horizontalCenter | |
| anchors.top: parent.top | |
| anchors.topMargin: 10 | |
| } | |
| Text { | |
| text: "Hello world!" | |
| anchors.horizontalCenter: parent.horizontalCenter | |
| anchors.verticalCenter: parent.verticalCenter | |
| font.pointSize: 18 | |
| } | |
| Text { | |
| text: explanation | |
| anchors.horizontalCenter: parent.horizontalCenter | |
| anchors.bottom: parent.bottom | |
| anchors.bottomMargin: 10 | |
| font.pointSize: 18 | |
| } | |
| } | |
| orientation: ListView.Horizontal | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment