2

我用“Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowSystemMenuHint” windowFlags 制作了一个 QWidget。

我重新实现了所有鼠标事件,以便能够移动/调整窗口大小。

我想做的最后一件事是能够获得与有关 Windows 7 Dock 系统的“普通窗口”相同的行为。

当我使用普通窗口将窗口移动到屏幕的左/右/顶部附近时,它会将其大小调整为 halfWindowSize 或全屏。

知道怎么做吗?

4

1 回答 1

0

Well that will be too obvious but still...

You need to listen move event and whenever you detect top-left <= 0 or top-right >= SCREEN_WIDTH you will manually re-size your window. Surely you need to get screen size before all those and calculate half of it and so on.

No need to mention that, in half-maximized state you need to listen and check if the window is moved to restore its previous dimensions.

I really believe there is no trivial way to implement this unless you are to use winapi. Well in winapi case one can object trivialness and I can't deny.

Please let us know if you eventually come up with an easier solution.

于 2013-01-24T09:24:50.687 回答