QtQuick2 dragging frameless window

后端 未结 4 2007
北恋
北恋 2020-12-10 06:17

I’m looking for a way of dragging frameless window in QtQuick2. I followed this thread on the forum Link but it gives me an error.

Main difference in the code is tha

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 06:47

    A rather complete example:

    import QtQuick 2.14
    import QtQuick.Controls 2.14
    
    ApplicationWindow {
        visible: true
        width: 200
        height: 200
        flags: Qt.FramelessWindowHint
        MouseArea {
            anchors.fill: parent
            onPressed: { pos = Qt.point(mouse.x, mouse.y) }
            onPositionChanged: {
                var diff = Qt.point(mouse.x - pos.x, mouse.y - pos.y)
                ApplicationWindow.window.x += diff.x
                ApplicationWindow.window.y += diff.y
            }
            property point pos
        }
    }
    

提交回复
热议问题