qt获取窗口的右上角位置_qt:将窗口移出屏幕后,如何将其移回到默认位置,包括默认定位行为?...

在Qt中,使用mainWindow.move(-50000, -50000)可将窗口移出屏幕,再用mainWindow.move(0, 0)返回默认位置。然而,这会导致窗口始终出现在(0,0)位置。为实现窗口管理器决定窗口位置,可以使用mainWindow.setAttribute(Qt::WA_Moved, false)来建议而非请求位置。但这无法解决通过show获取离屏窗口尺寸后再显示到屏幕上的问题,可能是个Qt的bug。" 116841457,10617368,蓝桥杯试题G解析:动态规划解决砝码称重问题,"['算法', '动态规划', '编程竞赛']
摘要由CSDN通过智能技术生成

[qt 4.8]

To get correct window dimensions including its frame, I do the following (as described e.g. here, see comment from Daniel Hedberg).

mainWindow.move(-50000, -50000);

mainWindow.show();

// do something with the window dimensions

mainWindow.move(0, 0);

mainWindow.show()

This works fine, however, I have a problem with the move(0,0) call: It makes the window always appear at position (0,0), while I would like to have the default behaviour, this is, the application only suggests to the window manager that (0,0) is a good place to position the window, and the WM might decide to shift it if necessary to avoid overlapping. In other words, I would like to switch back to Qt's default behaviour as if there weren't a call to move at all.

How can I do that?

解决方案

Looking into the source code of Qt, I can now partial

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值