//main.qml
Qt Code:
  1. import Qt 4.7
  2. import "content"
  3.  
  4. Rectangle {
  5.  
  6. width: 480; height: 480
  7. property int hr
  8. property int min
  9. property int am
  10.  
  11. signal titleBarClicked(int hr,int min,int am)
  12.  
  13.  
  14. Row {
  15. y: 0; x: 0; spacing: 20
  16.  
  17. Spinner {
  18. id: spinner
  19.  
  20. width: 60; height: 240
  21. focus: false
  22.  
  23. model: 13
  24. itemHeight: 30
  25.  
  26. delegate: Text { font.pixelSize: 25; text: index; height: 30 }
  27.  
  28.  
  29. }
  30.  
  31.  
  32. //Text { text: "Current item index: " + spinner.currentIndex }
  33.  
  34. }
  35. Row {
  36. y: 0; x: 80; spacing: 20
  37.  
  38. Spinner {
  39. id: spinner2
  40. width: 60; height: 240
  41. focus: true
  42. model: 60
  43. itemHeight: 30
  44. delegate: Text { font.pixelSize: 25; text: index; height: 30 }
  45. }
  46.  
  47.  
  48. // Text { text: "Current item index: " + spinner2.currentIndex }
  49.  
  50. }
  51. Row {
  52. y: 0; x: 160; spacing: 20
  53.  
  54. Spinner {
  55. id: spinner3
  56. width: 60; height: 240
  57. focus: true
  58. model: name1
  59. itemHeight: 30
  60.  
  61. delegate: Text {font.pixelSize: 25; text: "PM"; height: 30 }
  62.  
  63.  
  64. Text {
  65. id: name1
  66. text: ""
  67. }
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. }
  75.  
  76.  
  77.  
  78.  
  79. // Text { text: "Current item index: " + spinner3.currentIndex }
  80.  
  81. }
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. Column {
  90. y: 150; x: 220; spacing: 20
  91. Image {
  92. id: image1
  93. source: "content/forward.png"
  94.  
  95. MouseArea {
  96. id:mousearea
  97. anchors.fill: parent
  98. acceptedButtons: Qt.LeftButton | Qt.RightButton|Qt.MiddleButton
  99. onReleased: {
  100.  
  101. titleBarClicked(spinner.currentIndex,spinner2.currentIndex,spinner3.currentIndex)
  102. console.log("First currentIndex = "+ spinner.currentIndex )
  103. console.log("Second currentIndex = "+ spinner2.currentIndex )
  104. console.log("currentIndex = "+ spinner3.currentIndex )
  105.  
  106. }
  107.  
  108. }
  109.  
  110. }
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. }
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. }
To copy to clipboard, switch view to plain text mode 




.cpp file integration qt with qml
Qt Code:
  1. QDeclarativeView *qView=new QDeclarativeView(ui->graphicsView);
  2. qView->setSource(QString("main.qml"));
  3. QGraphicsObject *obj =qView->rootObject();
  4. connect ( obj,SIGNAL(titleBarClicked(int,int,int)), this, SLOT(timecal(int,int,int)));
To copy to clipboard, switch view to plain text mode 



error:

visual studio runtime error

error displayed on qt console

QGraphicsItem::ungrabMouse: not a mouse grabber
ASSERT: "!implicit" in file graphicsview\qgraphicsscene.cpp, line 906

when click and drag on the sides of spinners no error is displayed . but when clicked and dragged exactly on the spinner the above errors are displayed.
what should I do?