MainPage.qml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import QtQuick 1.1
  2. import com.meego 1.0
  3. Page {
  4. id: mainPage
  5. tools: commonTools
  6. Flickable {
  7. anchors.fill: parent
  8. contentHeight: parent.height*2
  9. id: flickable1
  10. Item {
  11. width: 200; height: 250
  12. Component {
  13. id: itemDelegate
  14. Row {
  15. spacing:5
  16. Rectangle {
  17. anchors.margins: 5
  18. height: 50
  19. width: 50
  20. color: "red"
  21. Rectangle {
  22. anchors.fill: parent
  23. anchors.topMargin: 5
  24. anchors.bottomMargin: 5
  25. color:"black"
  26. }
  27. MouseArea {
  28. anchors.fill: parent
  29. onClicked: { parent.color = 'green' }
  30. }
  31. }
  32. Text {
  33. font.pointSize: 18
  34. text: "I am item number: " + index
  35. MouseArea {
  36. anchors.fill: parent
  37. onClicked: {
  38. if (mouse.button==Qt.RightButton) {
  39. parent.color = 'yellow'
  40. } else {
  41. parent.color = 'yellow'
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48. ListView {
  49. anchors.fill: parent
  50. model: 5
  51. delegate: itemDelegate
  52. }
  53. }
  54. Label {
  55. id: label
  56. anchors.centerIn: parent
  57. text: qsTr("Hello world!")
  58. visible: false
  59. }
  60. TextInput {
  61. anchors.bottom : button1.top
  62. font.pointSize: 18
  63. width:parent.width
  64. height:50
  65. color: blue
  66. }
  67. Button{
  68. id: button1
  69. anchors.horizontalCenter: parent.horizontalCenter
  70. anchors.top: label.bottom
  71. anchors.topMargin: 10
  72. text: qsTr("Click here!")
  73. onClicked: label.visible=true
  74. }
  75. Button{
  76. id: button2
  77. anchors.horizontalCenter: parent.horizontalCenter
  78. anchors.top: button1.bottom
  79. anchors.topMargin: 10
  80. text: qsTr("hide label!")
  81. onClicked: label.visible=false
  82. }
  83. TextInput {
  84. id: textInput
  85. anchors {
  86. left: parent.left
  87. leftMargin: 8
  88. right: parent.right
  89. rightMargin: 8
  90. top: button2.bottom
  91. topMargin: 10
  92. }
  93. focus: true
  94. selectByMouse: true
  95. }
  96. }
  97. }