We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
操作系统:Win10 22H2 Qt版本:6.7.0 使用如下代码测试:
import QtQuick import QtQuick.Window import QtQuick.Controls import Qt.labs.platform import QWindowKit Window { id: window width: 800 height: 600 title: qsTr("Hello, world!") Component.onCompleted: { windowAgent.setup(window) window.visible = true } WindowAgent { id: windowAgent } MouseArea{ anchors.fill: parent onPressed: (mouse)=>{ var global = mapToGlobal(mouse.x,mouse.y) helper.setCursorPos(global.x,global.y) var local = mapFromGlobal(global.x,global.y) console.log("mouse:",mouse.x,mouse.y," global:",global," local:",local) } }
helper.setCursorPos(global.x,global.y) 是一个C++提供的函数,它仅仅是调用QCursor::setPos(x, y) 目前发现开启无边框窗口后,mapToGlobal得到的鼠标位置跟实际的鼠标位置会相差一个标题栏的高度,但是再使用mapFromGlobal还原得到的本地坐标确实正确的
表现情况如下:
The text was updated successfully, but these errors were encountered:
初步定位到CustomMargins会影响到鼠标映射
Sorry, something went wrong.
我们手动调用了setCustomMargins,就是为了消除这个问题
不调用肯定是不行的,我们必须通知Qt我们已经修改了margins,否则Qt内部维护的数据与我们不一致,会产生很多bug
明白,你们修改Margin应该是为了解决Render的问题吧? 但是CustomMargin会影响到Window的Geometry,从而导致MapToGlobal异常,虽然我能手动去矫正这个坐标的偏差,但这会不会给一些程序控件增加一些潜在的隐患?
你说的也很有道理,可能确实会导致暗病,我和 @SineStriker 再合计一下
SineStriker
No branches or pull requests
操作系统:Win10 22H2
Qt版本:6.7.0
使用如下代码测试:
helper.setCursorPos(global.x,global.y) 是一个C++提供的函数,它仅仅是调用QCursor::setPos(x, y)
目前发现开启无边框窗口后,mapToGlobal得到的鼠标位置跟实际的鼠标位置会相差一个标题栏的高度,但是再使用mapFromGlobal还原得到的本地坐标确实正确的
表现情况如下:
The text was updated successfully, but these errors were encountered: