How to let PathView display ListElement by order



  • i use a PathView to display picture,all pictures are from ListModel,but when it display,it does not
    by order which defined in ListModel



  • you mean..PathView does not display pictures in the order you gave in ListModel. It should display in the order you provide in ListModel. None of the *View models do sorting of Model before displaying.. Can you copy/paste the code???



  • the code is downed from internet
    @import Qt 4.7

    Rectangle {
    width: 800; height: 420
    color: "black"

    ListModel {
        id: myModel
        ListElement { picName: "pics/1.png" }
        ListElement { picName: "pics/2.png" }
        ListElement { picName: "pics/3.png" }
        ListElement { picName: "pics/4.png" }
        ListElement { picName: "pics/5.png" }
        ListElement { picName: "pics/6.png" }
        ListElement { picName: "pics/7.png" }
        
    }
    
    Component {
        id: myDelegate
    
        Item{
            width: 340
            height: 260
            visible: PathView.onPath
            z: PathView.zOrder
    
    
            Image{
                id:myImage
                width: 340
                height: 260
                source: picName
                anchors.horizontalCenter: parent.horizontalCenter
                smooth: true
            }
            Image {
                id: subImage
                width: 340
                height: 260
                source: picName
                anchors.horizontalCenter: parent.horizontalCenter
                smooth: true
                transform: Rotation { origin.x: 0; origin.y: 260; axis { x: 1; y: 0; z: 0 } angle: 180 }
            }
            Rectangle{
                y: myImage.height;
                x: -1
                width: myImage.width + 1
                height: myImage.height
                gradient: Gradient {
                    GradientStop { position: 0.0; color: Qt.rgba(0,0,0, 0.7) }
                }
            }
    
            transform:[
                Rotation{
                    angle: PathView.rotateY
                    origin.x: 340/2
                    axis { x: 0; y: 1; z: 0 }
                },
                Scale {
                    xScale:PathView.scalePic; yScale:PathView.scalePic
                    origin.x: 340/2;   origin.y: 260/2
                }
            ]
            MouseArea {
    
    
                anchors.fill: parent
    
    
    
                onClicked: view.currentIndex = index
    
    
    
            }
    
        }//Item
    }
    
    
    
    PathView {
        id: view
        focus: true
        model: myModel
        delegate: myDelegate
        anchors.fill: parent
        pathItemCount: 13
    
        preferredHighlightBegin: 0.5
        preferredHighlightEnd: 0.5
        highlightRangeMode: PathView.StrictlyEnforceRange
    
        flickDeceleration: 390
        path: myPath
    }
    
    Path {
        id: myPath
        startX: 0; startY: 150
        PathAttribute {name: "rotateY"; value: 50.0}
        PathAttribute {name: "scalePic"; value: 0.5}
        PathAttribute {name: "zOrder"; value: 1}
    
        PathLine{x:180; y: 150}
        PathPercent {value: 0.44}
        PathAttribute {name: "rotateY"; value: 50.0}
        PathAttribute {name: "scalePic"; value: 0.5}
        PathAttribute {name: "zOrder"; value: 10}
    
        PathQuad{x:320; y: 190; controlX: 290; controlY: 190}
        PathPercent {value: 0.50}
        PathAttribute {name: "rotateY"; value: 0.0}
        PathAttribute {name: "scalePic"; value: 1.0}
        PathAttribute {name: "zOrder"; value: 50}
    
        PathQuad{x:460; y: 150; controlX: 510; controlY: 150}
        PathPercent {value: 0.56}
        PathAttribute {name: "rotateY"; value: -50.0}
        PathAttribute {name: "scalePic"; value: 0.5}
        PathAttribute {name: "zOrder"; value: 10}
    
        PathLine{x:640; y: 150}
        PathPercent {value: 1.00}
        PathAttribute {name: "rotateY"; value: -50.0}
        PathAttribute {name: "scalePic"; value: 0.5}
        PathAttribute {name: "zOrder"; value: 1}
    }
    

    }

    @



  • sorry i forget say this use click can display in order,but i want to use drag to implement the same function


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.