I've loaded a PNG image into my QML code and enabled dragging on it.
Image {
source: "image.png"
width: 128
height: 128
MouseArea {
anchors.fill: parent
drag.target: parent
}
}
The problem is that the whole image is selectable, even the transparent parts which I need to disable selecting on these areas. I even tried to make the Canvas
from the image, but the problem remains.
Canvas {
width: 128
height: 128
Component.onCompleted: loadImage("image.png")
onImageLoaded: requestPaint()
onPaint: {
var ctx = getContext("2d")
var im = ctx.createImageData("image.png")
im.data[3] = 128
ctx.drawImage(im, 0, 0)
}
MouseArea {
anchors.fill: parent
drag.target: parent
}
}
Here is the image which the only red part should be selectable:
Any idea?