fix: 窗口居中加Screen.virtualX/virtualY偏移适配多显示器

原 Screen.width/height 居中在虚拟桌面原点,多显示器下窗口可能出
现在非预期屏幕。加 virtualX/virtualY 偏移后在任务栏所在屏幕内居中。
This commit is contained in:
2026-07-24 09:57:32 +08:00
parent 9803c59e76
commit 6d17f638e7
4 changed files with 15 additions and 9 deletions
+4 -2
View File
@@ -48,8 +48,10 @@ Window {
onVisibleChanged: {
if (visible) {
x = (Screen.width - width) / 2
y = (Screen.height - height) / 2
// 居中到当前屏幕(任务栏所在屏幕),加 virtualX/virtualY 偏移
// 避免多显示器下窗口出现在非预期屏幕
x = Screen.virtualX + (Screen.width - width) / 2
y = Screen.virtualY + (Screen.height - height) / 2
}
}