QML FramelessWindow moving
-
Hello! I have window with FramelessWindowHint and i want to move it. In Qt5.11.2 i used this code:
Window { width: 1366 height: 768 flags: Qt.Window | Qt.FramelessWindowHint | Qt.WindowMinimizeButtonHint MouseArea { property int previousX: 0 property int previousY: 0 property var moveObject: parent; anchors.fill: parent onPressed: { previousX = mouseX previousY = mouseY } onPositionChanged: { moveObject.x += mouseX - previousX moveObject.y += mouseY - previousY } } }
After update to 5.12 it works wrong. So what to do?
P.S: build with msvc2017x64
-
What is happening ? Window moving ? Wrong move ? Did u try printing the value of moise position. Are they coming correct? Please note you are not changing the parent values. You are changing the another object altogether. Hence it does not work.
-
specially I tested today this problem on qt5.11.2, qt5.11.3 and qt5.12. So with 5.11.2 all right. With 5.11.3 and 5.12 window jump side to side and can get coordinates over screen (for example -14000). And that interesting i change line from
onPositionChanged: { moveObject.x += mouseX - previousX moveObject.y += mouseY - previousY }
to simple code
onPositionChanged: { moveObject.x++ }
When i press mouse and move it to global left corner screen (0,0) and dont move mouse. In qt5.11.2 window can't get signal onPositionChanged and window not moving, but in 5.11.3 and 5.12 it's moving, because get signal.
PS: problem was solved with using QCursor::pos().
-
If you see inconsistent behaviour file a bug. Please note your moveobject assigned with parent. So when the x changes with parent it will not reevaluate moveobject. Hence it will move window. How about giving identity to topwindow and change x and y directly. Or use alias for parent as moveobject. Alias should be defined with identity property and not with parent