Ubuntu Pastebin

Paste from mardy at Fri, 14 Aug 2015 11:48:54 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import QtQuick 2.0                                                                   
                                                                                     
Item {                                                                               
    id: root                                                                         
                                                                                     
    property int initialIndex: -1                                                    
                                                                                     
    anchors.fill: parent                                                             
                                                                                     
    ListView  {                                                                      
        id: listView
        objectName: "listView"                                                       
        anchors.fill: parent                                                         
                                                                                     
        onCurrentIndexChanged: console.log("Current index changed to " + currentIndex)        
        onModelChanged: console.log("Model changed to " + model)
        onCountChanged: {                                                            
            console.log("Count changed to " + count)
            if (count > 0 && initialIndex >= 0) {                                    
                console.log("Setting current index to " + initialIndex)
                currentIndex = initialIndex; 
                initialIndex = -1;
            }   
        }   
        
        delegate: Rectangle {                                                        
            id: preview
            objectName: "preview" + index                                            
            height: listView.height
            width: listView.width
            color: "green"
        }   
    }   
    
    MouseArea {
        anchors.fill: parent
        onClicked: {
            root.initialIndex = -1
            root.initialIndex = 3
            listView.model = 10
        }
    }
}
Download as text