Qt Forum,
This is to state an issue regarding a problem of overlapping qml components.
The requirement of our application is to get some value on touch points with a marker
and one touching the same point again, the marker is removed.
We are using repeaters to create components at respecting x,y cordinates.
1. The window consists of a grid of small cells which cover the whole window.
2. As the user clicks the screen, the coordinates and grid cell index is send to cpp
and respective temperature is returned to the qml.
3. We are using MVC architecture to
store the temperate , grid index and coordinates of one marker component and
use repeater to display on the screen.
4. We created a marker component in qml and used the component to show the point touched
by user with the corresponding temperature
5. When the user clicks back on same grod index, the marker present tere is removed.
Now, the problem occurs that when more than one markers are close to each other, they overlapp
and its difficult to make out the readings.
We used mouse propogation technique to stop qml to send grid cells to cpp very near to any other point.
//
Repeater {
id: repeater
anchors.fill: parent
model: temperatureModel
delegate: Item {
id: markerItem
x: screenCoordinate.x-width/2
y: screenCoordinate.y-height/2
width: 200
height: 200
TemperatureMarkerView {
width: 50
height: 50
anchors.centerIn: parent
temp: temperature
displayRight: (videoItemRect.width - screenCoordinate.x) > width ? true : false
}
MouseArea {
anchors.fill: parent
onClicked: {
mouse.accepted = true // this line does not allow the qml to send grid index to
// cpp for when user click inside the container which contains
// current marker
}
}
}
}
//
Repeater {
id: repeater
anchors.fill: parent
model: temperatureModel
delegate: Item {
id: markerItem
x: screenCoordinate.x-width/2
y: screenCoordinate.y-height/2
width: 200
height: 200
TemperatureMarkerView {
width: 50
height: 50
anchors.centerIn: parent
temp: temperature
displayRight: (videoItemRect.width - screenCoordinate.x) > width ? true : false
}
MouseArea {
anchors.fill: parent
onClicked: {
mouse.accepted = true // this line does not allow the qml to send grid index to
// cpp for when user click inside the container which contains
// current marker
}
}
}
}
To copy to clipboard, switch view to plain text mode
But the problem here is that, since qml doesnt send the grid index back, the cpp cannot delete the already present marker as well
Bookmarks