jakr13
25th November 2015, 11:29
Hi Everyone,
I am a newbie to QML and I wanted to select some rectangle ROI's in an Image. I am getting co-ordinates during mouse press and release event. Now, I need to start drawing a rectangle during mouse press event and end the rectangle during mouse release event. I have done this using Qt Widgets application, but I was thinking to implement the same in QML. Can someone guide me to implement this.
Here's my code
import QtQuick 1.1
Rectangle {
id:imageRect
width: 300
height: 300
property int pressX
property int pressY
property int releaseX
property int releaseY
Image{
id:imagetoshow
source:"file:///C://Users//Jakr13//Desktop//testimage.bmp"
}
MouseArea {
id:roiRectArea
anchors.fill: parent
onPressed: {
pressX = mouse.x
pressY = mouse.y
console.log("Pressed Co-ordinates",pressX,pressY);
}
onReleased: {
releaseX = mouse.x
releaseY = mouse.y
console.log("Released Co-ordinates",releaseX,releaseY);
}
}
}
Please feel free to point if there is anything wrong with my code or the way I am implementing is completely wrong.
Thanks in advance
Jakr13
I am a newbie to QML and I wanted to select some rectangle ROI's in an Image. I am getting co-ordinates during mouse press and release event. Now, I need to start drawing a rectangle during mouse press event and end the rectangle during mouse release event. I have done this using Qt Widgets application, but I was thinking to implement the same in QML. Can someone guide me to implement this.
Here's my code
import QtQuick 1.1
Rectangle {
id:imageRect
width: 300
height: 300
property int pressX
property int pressY
property int releaseX
property int releaseY
Image{
id:imagetoshow
source:"file:///C://Users//Jakr13//Desktop//testimage.bmp"
}
MouseArea {
id:roiRectArea
anchors.fill: parent
onPressed: {
pressX = mouse.x
pressY = mouse.y
console.log("Pressed Co-ordinates",pressX,pressY);
}
onReleased: {
releaseX = mouse.x
releaseY = mouse.y
console.log("Released Co-ordinates",releaseX,releaseY);
}
}
}
Please feel free to point if there is anything wrong with my code or the way I am implementing is completely wrong.
Thanks in advance
Jakr13