[Solved] iOS Style Rearrange of Icons

Page  
2

December 13, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

Also, if I use flow with a mousearea over it, how would I reparent each of the items in QML?

December 13, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

So far this is my flow implementation and it runs and the icons squiggle but I cannot move the widgets around:

  1. import Qt 4.7
  2.  
  3. Rectangle {
  4.     width: 640
  5.     height: 480
  6.     color: "#000000"
  7.  
  8.     Flow {
  9.         id:flowtest
  10.         x: 0
  11.         y: 0
  12.         anchors.rightMargin: 0
  13.         anchors.bottomMargin: 4
  14.         anchors.leftMargin: 8
  15.         anchors.topMargin: 4
  16.              anchors.fill: parent
  17.              anchors.margins: 4
  18.              spacing: 10
  19.  
  20.  
  21.             Image {
  22.                 source: "Images/widget.png"
  23.                 id: number1
  24.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number1.x; to: number1.x + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  25.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number1.y; to: number1.y + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  26.             }
  27.             Image {
  28.                 source: "Images/widget.png"
  29.                 id: number2
  30.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number2.x; to: number2.x - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  31.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number2.y; to: number2.y - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  32.             }
  33.             Image {
  34.                 source: "Images/widget.png"
  35.                 id: number3
  36.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number3.x; to: number3.x + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  37.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number3.y; to: number3.y + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  38.             }
  39.             Image {
  40.                 source: "Images/widget.png"
  41.                 id: number4
  42.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number4.x; to: number4.x - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  43.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number4.y; to: number4.y - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  44.             }
  45.             Image {
  46.                 source: "Images/widget.png"
  47.                 id: number5
  48.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number5.x; to: number5.x + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  49.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number5.y; to: number5.y + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  50.             }
  51.             Image {
  52.                 source: "Images/widget.png"
  53.                 id: number6
  54.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number6.x; to: number6.x - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  55.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number6.y; to: number6.y - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  56.             }
  57.             Image {
  58.                 source: "Images/widget.png"
  59.                 id: number7
  60.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number7.x; to: number7.x - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  61.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number7.y; to: number7.y - 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  62.             }
  63.             Image {
  64.                 source: "Images/widget.png"
  65.                 id: number8
  66.                 PropertyAnimation on x { running: number1.state=="squiggle"; from: number8.x; to: number8.x + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  67.                 PropertyAnimation on y { running: number1.state=="squiggle"; from: number8.y; to: number8.y + 1; duration: 100; loops: Animation.Infinite; easing.type: Easing.OutInBounce }
  68.             }
  69.  
  70.  
  71.  
  72.                     Transition {
  73.                              NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
  74.  
  75.                          }
  76.  
  77.  
  78.     }
  79.  
  80.     MouseArea {
  81.         id: mouse_area1
  82.         x: 0
  83.         y: 0
  84.         width: 640
  85.         height: 480
  86.         drag.target: number1
  87.         onPressAndHold:{
  88.  
  89.             if(number1.state != "squiggle")
  90.                 {
  91.  
  92.             number1.state="squiggle"
  93.             number2.state="squiggle"
  94.             number3.state="squiggle"
  95.             number4.state="squiggle"
  96.             number5.state="squiggle"
  97.             number6.state="squiggle"
  98.             number7.state="squiggle"
  99.             number8.state="squiggle"
  100.  
  101.  
  102.             }
  103.  
  104.             else
  105.                 {
  106.                 number1.state="Base State"
  107.                 number2.state="Base State"
  108.                 number3.state="Base State"
  109.                 number4.state="Base State"
  110.                 number5.state="Base State"
  111.                 number6.state="Base State"
  112.                 number7.state="Base State"
  113.                 number8.state="Base State"
  114.  
  115.             }
  116.  
  117.         }
  118.     }
  119.  
  120. }

December 14, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

I don’t now that reparenting was the right word to use. I just want to move them and have them snap to a new location while the other icons fill in around it.

December 15, 2010

xsacha xsacha
Lab Rat
517 posts

This has been made in to a Wiki Entry: http://developer.qt.nokia.com/wiki/Drag_and_Drop_within_a_GridView

 Signature 

- Sacha

December 15, 2010

Bradley Bradley
Lab Rat
314 posts

I’ve updated the above wiki entry with an alternate implementation.

 Signature 

Nokia Certified Qt Specialist.

January 20, 2011

coldmilk coldmilk
Lab Rat
1 posts

I used the code in the following path, but when i added more list modle element in the list , i can’t scroll the list if i want to move the last element in the end, what should i do ?

This has been made in to a Wiki Entry: http://developer.qt.nokia.com/wiki/Drag_and_Drop_within_a_GridView

Page  
2

  ‹‹ currentItem and currentIndex for ListView      Stirring Qt Quick into the mix ››

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