June 10, 2011

sfjam sfjam
Lab Rat
29 posts

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

3 replies

June 10, 2011

Vijay Bhaska Reddy Vijay Bhaska Reddy
Lab Rat
383 posts

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???

June 10, 2011

sfjam sfjam
Lab Rat
29 posts

the code is downed from internet

  1. import Qt 4.7
  2.  
  3.  
  4. Rectangle {
  5.     width: 800; height: 420
  6.     color: "black"
  7.  
  8.     ListModel {
  9.         id: myModel
  10.         ListElement { picName: "pics/1.png" }
  11.         ListElement { picName: "pics/2.png" }
  12.         ListElement { picName: "pics/3.png" }
  13.         ListElement { picName: "pics/4.png" }
  14.         ListElement { picName: "pics/5.png" }
  15.         ListElement { picName: "pics/6.png" }
  16.         ListElement { picName: "pics/7.png" }
  17.        
  18.     }
  19.  
  20.     Component {
  21.         id: myDelegate
  22.  
  23.         Item{
  24.             width: 340
  25.             height: 260
  26.             visible: PathView.onPath
  27.             z: PathView.zOrder
  28.  
  29.  
  30.             Image{
  31.                 id:myImage
  32.                 width: 340
  33.                 height: 260
  34.                 source: picName
  35.                 anchors.horizontalCenter: parent.horizontalCenter
  36.                 smooth: true
  37.             }
  38.             Image {
  39.                 id: subImage
  40.                 width: 340
  41.                 height: 260
  42.                 source: picName
  43.                 anchors.horizontalCenter: parent.horizontalCenter
  44.                 smooth: true
  45.                 transform: Rotation { origin.x: 0; origin.y: 260; axis { x: 1; y: 0; z: 0 } angle: 180 }
  46.             }
  47.             Rectangle{
  48.                 y: myImage.height;
  49.                 x: -1
  50.                 width: myImage.width + 1
  51.                 height: myImage.height
  52.                 gradient: Gradient {
  53.                     GradientStop { position: 0.0; color: Qt.rgba(0,0,0, 0.7) }
  54.                 }
  55.             }
  56.  
  57.             transform:[
  58.                 Rotation{
  59.                     angle: PathView.rotateY
  60.                     origin.x: 340/2
  61.                     axis { x: 0; y: 1; z: 0 }
  62.                 },
  63.                 Scale {
  64.                     xScale:PathView.scalePic; yScale:PathView.scalePic
  65.                     origin.x: 340/2;   origin.y: 260/2
  66.                 }
  67.             ]
  68.             MouseArea {
  69.  
  70.  
  71.                 anchors.fill: parent
  72.  
  73.  
  74.  
  75.                 onClicked: view.currentIndex = index
  76.  
  77.  
  78.  
  79.             }
  80.  
  81.         }//Item
  82.     }
  83.  
  84.  
  85.  
  86.     PathView {
  87.         id: view
  88.         focus: true
  89.         model: myModel
  90.         delegate: myDelegate
  91.         anchors.fill: parent
  92.         pathItemCount: 13
  93.  
  94.         preferredHighlightBegin: 0.5
  95.         preferredHighlightEnd: 0.5
  96.         highlightRangeMode: PathView.StrictlyEnforceRange
  97.  
  98.         flickDeceleration: 390
  99.         path: myPath
  100.     }
  101.  
  102.     Path {
  103.         id: myPath
  104.         startX: 0; startY: 150
  105.         PathAttribute {name: "rotateY"; value: 50.0}
  106.         PathAttribute {name: "scalePic"; value: 0.5}
  107.         PathAttribute {name: "zOrder"; value: 1}
  108.  
  109.         PathLine{x:180; y: 150}
  110.         PathPercent {value: 0.44}
  111.         PathAttribute {name: "rotateY"; value: 50.0}
  112.         PathAttribute {name: "scalePic"; value: 0.5}
  113.         PathAttribute {name: "zOrder"; value: 10}
  114.  
  115.         PathQuad{x:320; y: 190; controlX: 290; controlY: 190}
  116.         PathPercent {value: 0.50}
  117.         PathAttribute {name: "rotateY"; value: 0.0}
  118.         PathAttribute {name: "scalePic"; value: 1.0}
  119.         PathAttribute {name: "zOrder"; value: 50}
  120.  
  121.         PathQuad{x:460; y: 150; controlX: 510; controlY: 150}
  122.         PathPercent {value: 0.56}
  123.         PathAttribute {name: "rotateY"; value: -50.0}
  124.         PathAttribute {name: "scalePic"; value: 0.5}
  125.         PathAttribute {name: "zOrder"; value: 10}
  126.  
  127.         PathLine{x:640; y: 150}
  128.         PathPercent {value: 1.00}
  129.         PathAttribute {name: "rotateY"; value: -50.0}
  130.         PathAttribute {name: "scalePic"; value: 0.5}
  131.         PathAttribute {name: "zOrder"; value: 1}
  132.     }
  133. }

June 10, 2011

sfjam sfjam
Lab Rat
29 posts

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

 
  ‹‹ use a c++ class as singleton inside qml files      indexAt() of ListView fails with QSortFilterProxyModel enabled ››

You must log in to post a reply. Not a member yet? Register here!