Hi Qt Masters,

Here i am again consulting my current issue.

I am currently implementing a level indicator, which is working perfectly already using the onclicked method.
However, I wanted to add a drag capability, wherein the level will increase or decrease when dragged to the right or left, respectively.

Btw, i am using a repeater to populate the images, here's the code:

Qt Code:
  1. Repeater
  2. {
  3. property int level: -1
  4. id:levelRepeater
  5. model: 15
  6.  
  7. Image {
  8. source: "/images/bar.png"
  9. id: levelImg
  10.  
  11. MouseArea {
  12. id: levelArea
  13. anchors.fill: parent
  14. onClicked: { level = index }
  15. }
  16. }
  17. }
To copy to clipboard, switch view to plain text mode 

Now, I wanted to implement the drag capability. I initially thought of using the mouseX position since this is positioned horizontally.
I noticed that there were 25 pixels in every image, it has x values from 0-24.

Qt Code:
  1. onMouseXChanged: { if (mouseX % 25 == 0) { level++ } } //this is only for dragging to the right
To copy to clipboard, switch view to plain text mode 

Then I noticed that when dragging to the left, the mouseX value decreases from the initial value to 0 then to negative values once it reaches to another mouse area on the left of the current index.

Maybe, you already encountered this kind if issue please advise, any help is greatly appreciated.

TIA.