I would like to create a range age selector. To do this, a control to select a number is created:

SpinnerInt.qml

Qt Code:
  1. import QtQuick 2.0
  2.  
  3. ListView {
  4. id: root
  5. property alias maxString: textSize.text
  6. property int shadowHeight
  7. property int minValue: 0
  8. onMinValueChanged: {
  9. var lastValue = value
  10. modelValues = maxValue - minValue + 1
  11. if (lastValue > value) {
  12. currentIndex = lastValue - minValue
  13. }
  14. }
  15. property int maxValue: 0
  16. onMaxValueChanged: {
  17. modelValues = maxValue - minValue + 1
  18. }
  19. property int value: 0
  20. function setValue(newValue) {
  21. currentIndex = newValue - minValue
  22. }
  23. property int iniValue: 0
  24. Text {
  25. id: textSize
  26. visible: false
  27. font.pixelSize: 24
  28. }
  29.  
  30. onCurrentIndexChanged: {
  31. value = currentIndex + minValue
  32. }
  33.  
  34. property int modelValues
  35. highlightRangeMode: ListView.StrictlyEnforceRange
  36. width: textSize.width
  37. height: textSize.height + (2 * shadowHeight)
  38. preferredHighlightBegin: shadowHeight
  39. preferredHighlightEnd: height - shadowHeight
  40. clip: true
  41. model: modelValues
  42. delegate: Text {
  43. color: currentIndex == index ? "black" : "lightgray";
  44. text: index + minValue
  45. font.pixelSize: 24
  46. anchors.horizontalCenter: parent.horizontalCenter
  47. }
  48. Component.onCompleted: {
  49. var i = iniValue - minValue
  50. if (i >= 0) {
  51. currentIndex = i
  52. }
  53. }
  54. }
To copy to clipboard, switch view to plain text mode 

The main.qml looks like this:

Qt Code:
  1. import QtQuick 2.5
  2. import QtQuick.Controls 1.4
  3.  
  4. ApplicationWindow {
  5. visible: true
  6. width: 640
  7. height: 480
  8. Row {
  9. spacing: 20
  10. SpinnerInt {
  11. id: ageMin
  12. shadowHeight: 20
  13. maxString: "MM"
  14. minValue: 15
  15. maxValue: 99
  16. iniValue: 20
  17. }
  18. SpinnerInt {
  19. id: ageMax
  20. shadowHeight: 20
  21. maxString: "MM"
  22. minValue: ageMin.value
  23. maxValue: 99
  24. iniValue: 20
  25. }
  26. }
  27. }
To copy to clipboard, switch view to plain text mode 

Note that the property minValue on ageMax is binding with ageMin.value.

If is tested with qmlscene, all works fine, but if runs the program, it crash in qsharedpointer.cpp.

Why is crashing only on runtime? How can I fix it?