Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Why cursor is moved to 0,0 when I use setGeometry?



  • I want to press left mouse button and move window to other position. Generally everything is ok, but I don't know, why cursor is moved to position 0,0.

            onPositionChanged:
            {
                if (mouse.buttons == Qt.LeftButton)
                {
                    console.log("Mouse: X:Y: " + mouseX + ":" + mouseY)
                    console.log("Window: X:Y: " + mainWindow.x + ":" + mainWindow.y)
                    console.log(mapToGlobal(mouseX, mouseY))
    
                    var windowGeometry = mapToGlobal(mouseX, mouseY)
                    mainWindow.setGeometry(windowGeometry.x, windowGeometry.y , mainWindow.width, mainWindow.height)
    
                }
            }
    

Log in to reply