here is My Qml

Qt Code:
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the QtDeclarative module of the Qt Toolkit.
  8. **
  9. ** $QT_BEGIN_LICENSE:BSD$
  10. ** You may use this file under the terms of the BSD license as follows:
  11. **
  12. ** "Redistribution and use in source and binary forms, with or without
  13. ** modification, are permitted provided that the following conditions are
  14. ** met:
  15. ** * Redistributions of source code must retain the above copyright
  16. ** notice, this list of conditions and the following disclaimer.
  17. ** * Redistributions in binary form must reproduce the above copyright
  18. ** notice, this list of conditions and the following disclaimer in
  19. ** the documentation and/or other materials provided with the
  20. ** distribution.
  21. ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
  22. ** the names of its contributors may be used to endorse or promote
  23. ** products derived from this software without specific prior written
  24. ** permission.
  25. **
  26. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  30. ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  31. ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33. ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  34. ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  37. ** $QT_END_LICENSE$
  38. **
  39. ****************************************************************************/
  40.  
  41. import Qt 4.7
  42.  
  43.  
  44.  
  45. Rectangle {
  46. id:myrect
  47. width: 1000; height: 450
  48. color: "#ffc021"
  49. property int selectedBeerNumber: -1
  50. property int songno
  51. x:15
  52. y:15
  53.  
  54.  
  55.  
  56. signal titleBarClicked(int songno)
  57.  
  58. MouseArea {
  59. anchors.fill: parent
  60. onClicked: grid.currentIndex = -1
  61.  
  62.  
  63.  
  64. }
  65.  
  66. ListModel {
  67. id: appModel
  68.  
  69. ListElement { name: " 1"; icon: "pics/1a.png"; titledes:"The ";itemno:1;}
  70. ListElement { name: "2"; icon: "pics/1b.png"; titledes:"My ";itemno:2}
  71. ListElement { name: " 3"; icon: "pics/1c.png"; titledes:" Ok!";itemno:3}
  72.  
  73.  
  74. ListElement { name: "Dr 1"; icon: "pics/4a.png";titledes:" Banana Phone!" ;itemno:4}
  75. ListElement { name: "Dr 2"; icon: "pics/4b.png";titledes:"Airplanes!" ;itemno:5}
  76. ListElement { name: "Dr 3"; icon: "pics/4c.png";titledes:"Rap!" ;itemno:6}
  77.  
  78.  
  79.  
  80. ListElement { name: "Br 1"; icon: "pics/6a.png" ;titledes:" Dreams!";itemno:7}
  81. ListElement { name: "Br 2"; icon: "pics/6b.png" ;titledes:" Blessings!";itemno:8}
  82. ListElement { name: "Br 3"; icon: "pics/6c.png" ;titledes:" You!";itemno:9}
  83.  
  84.  
  85.  
  86.  
  87. ListElement { name: "D 1"; icon: "pics/3a.png";titledes:"Ice and Me!";itemno:10 }
  88. ListElement { name: "D 2"; icon: "pics/3b.png";titledes:"Something New!" ;itemno:11}
  89.  
  90.  
  91.  
  92.  
  93.  
  94. ListElement { name: "Ts 1"; icon: "pics/5.png" ;titledes:"Skip Step!";itemno:12}
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. ListElement { name: "S1"; icon: "pics/2.png";titledes:"Friend!";itemno:13 }
  105. ListElement { name: "g 1"; icon: "pics/9.png";titledes: "Song!";itemno:14}
  106. ListElement { name: "1"; icon: "pics/11.png";titledes: "Think Positive!";itemno:15}
  107. ListElement { name: " Baby"; icon: "pics/10.png" ;titledes:"Star!";itemno:16}
  108. ListElement { name: "Team 1"; icon: "pics/chumma.png";titledes :"All Characters Video!";itemno:17}
  109. ListElement { name: "fun"; icon: "pics/7.png" ;titledes:"Sharing !";itemno:18}
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. }
  125.  
  126. Component {
  127. id: appDelegate
  128.  
  129.  
  130. Item {
  131.  
  132. id: chumma
  133. y:10;width: 150; height: 170
  134.  
  135.  
  136.  
  137.  
  138. // MouseArea {
  139. // anchors.fill: parent
  140.  
  141. // onClicked: Qt.openUrlExternally("http://www.dreamalings.com/iphone-videos.html");
  142. // hoverEnabled: true
  143.  
  144. // }
  145. // states: [
  146. // State {
  147. // name: "none"
  148. // when: (grid.currentIndex == -1)
  149. // },
  150. // State {
  151. // name: "selected"
  152. // when: rect.GridView.isCurrentItem
  153. // PropertyChanges {
  154. // target: rect;
  155. // width: 100;
  156. // height: 100
  157. // }
  158. // }
  159. // ]
  160. // transitions: Transition {
  161. // PropertyAnimation {
  162. // target: rect
  163. // properties: "width, height"
  164. // }
  165.  
  166.  
  167.  
  168.  
  169.  
  170. Image {
  171. width:95;
  172. height:95;
  173. x: 80;
  174. id: myIcon
  175. y: 20; anchors.horizontalCenter: parent.horizontalCenter;
  176. source: icon
  177.  
  178.  
  179. }
  180. Text {
  181. id:textnew;
  182. anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter }
  183.  
  184.  
  185. font.bold : true;font.italic:false;font.family: "Helvetica";
  186. font.pointSize:11;color: "Red"
  187. text:name
  188.  
  189. }
  190. Text {
  191. anchors { top: textnew.bottom; horizontalCenter: parent.horizontalCenter }
  192.  
  193. font.bold : false;font.italic:false;font.family: "Times New Roman";
  194. font.pointSize:9;color: "#0b5a43"
  195. text: titledes
  196. }
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. MouseArea {
  206. id:mousearea
  207. anchors.fill: parent
  208. acceptedButtons: Qt.LeftButton | Qt.RightButton|Qt.MiddleButton
  209.  
  210. onClicked: {
  211.  
  212.  
  213.  
  214.  
  215. myrect.state='selected'
  216. selectedBeerNumber = itemno;
  217. titleBarClicked(itemno)
  218.  
  219. if (mouse.button == Qt.RightButton)
  220. console.log(" Right Button Clicked");
  221.  
  222. else if(mouse.button == Qt.LeftButton)
  223.  
  224. console.log(" Left Button Clicked");
  225. else
  226. console.log("Middle Button Clicked");
  227.  
  228. //console.log("Clicked");
  229.  
  230.  
  231. // { if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething(); }
  232.  
  233. }
  234. }
  235. states: [
  236. State {
  237. name: "selected"
  238.  
  239. when: (itemno==selectedBeerNumber)
  240.  
  241.  
  242.  
  243.  
  244. //PropertyChanges {target: chumma;color:"lightblue"}
  245.  
  246. },
  247. State
  248.  
  249. {
  250.  
  251. name: "normal"
  252.  
  253. // This state will be activated if mouse button is pressed
  254.  
  255. when: mousearea.pressed
  256.  
  257. PropertyChanges { target: chumma; }
  258.  
  259. }
  260. ]
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267. }
  268. }
  269.  
  270. // Component {
  271.  
  272. // id: appHighlight
  273. // Rectangle { width: 0; height: 80; color: "lightsteelblue" }
  274. // }
  275.  
  276. GridView {
  277. id: grid
  278.  
  279. anchors.fill: parent
  280. cellWidth: 155; cellHeight: 140
  281. //highlight: appHighlight
  282. focus: true
  283. model: appModel
  284. delegate: appDelegate
  285.  
  286. flickableChildren:
  287. MouseArea {
  288. anchors.fill: parent
  289. onClicked: grid.currentIndex = -1
  290.  
  291.  
  292. }
  293.  
  294. // sets the initial index to -1, so no item is selected
  295. // currentIndex: -1 // not enough, need to check later
  296. Component.onCompleted: currentIndex = -1
  297.  
  298. }
  299. }
To copy to clipboard, switch view to plain text mode