joko
1st December 2014, 18:44
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:
Repeater
{
property int level: -1
id:levelRepeater
model: 15
Image {
source: "/images/bar.png"
id: levelImg
MouseArea {
id: levelArea
anchors.fill: parent
onClicked: { level = index }
}
}
}
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.
onMouseXChanged: { if (mouseX % 25 == 0) { level++ } } //this is only for dragging to the right
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.
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:
Repeater
{
property int level: -1
id:levelRepeater
model: 15
Image {
source: "/images/bar.png"
id: levelImg
MouseArea {
id: levelArea
anchors.fill: parent
onClicked: { level = index }
}
}
}
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.
onMouseXChanged: { if (mouseX % 25 == 0) { level++ } } //this is only for dragging to the right
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.