Help with crosshair
-
@oria66 Yes, thanks so much
here is
MouseArea { anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton onPositionChanged:(mouse)=> { actualLatLon.text= geoplotModel.getMousePosition(mouse.x,mouse.y); crosshair_y_axis.x = mouse.x-2; crosshair_y_axis.y = mouse.y - crosshair_y_axis.height/2; crosshair_x_axis.x = mouse.x- crosshair_x_axis.width/2; crosshair_x_axis.y = mouse.y - 2; } //onPressed:(mouse)=> mouse.accepted = false cursorShape: Qt.CrossCursor onEntered: { crosshair_y_axis.visible = true crosshair_x_axis.visible = true } onPressed: (mouse) => { if(mouse.button === Qt.RightButton){ geoplotModel.saveRightClickPosition(mouse.x,mouse.y) } mouse.accepted = false; } } } Rectangle{ id: crosshair_y_axis height:1500 width: 4 color: "black" } Rectangle{ id: crosshair_x_axis width: 2500 height: 4 color: "black" }
-
Unfortunately there's not much to be done, it's due to the rendering loop of Qt and the VSync of your screen.
Here's a relevant mailing list discussion : https://lists.qt-project.org/pipermail/interest/2014-March/011692.htmlOn my 50 Hz screen this issue is very noticeable, on my 144 Hz screen it is not an issue at all.
BTW I've changed your code to be able to run it and make it simpler:
HoverHandler { onPointChanged: { crosshair_x_axis.y = point.position.y - 1 crosshair_y_axis.x = point.position.x - 1 } } Rectangle{ id: crosshair_y_axis height: parent.height width: 3 color: "black" } Rectangle{ id: crosshair_x_axis width: parent.width height: 3 color: "black" }
-
@BeatrizGM One simple hack is to hide the mouse cursor when it is in that area. If you have the crosshair you dont need the mouse to be visible, right ? And if you do, you can simulate a mouse cursor with a image at the crosshair position, the delay will be the same that the crosshair, so it will not be noticeable
-
@GrecKo You are right, the lag is there. But in some use cases the lag is just visual hassle, does not interfere with the work. I work with cad software, I have a Bricscad license, afaik they use Qt for development, and the mouse is hidden in the drawing area, where the crosshair is active, the same with other cad's like Progecad and Autocad.
Of course in some uses cases that I am not aware, the lag can be problematic.
Anyway thanks for the link, I didnt have a clue why that happens. I am developing a app that has the same problem, I will now also test it in my both monitors.