PyQt4 - 平滑窗口调整大小过渡?

发布于 2024-12-20 20:09:34 字数 503 浏览 3 评论 0原文

当用户在 PyQt4 驱动的 GUI 的 QMainWindow 内打开特定选项卡时,
窗口需要自动调整大小,以便适合该特定选项卡的内容。

如您所知,当使用 Qwidget.resize() 时,窗口(PC 上默认)会立即调整大小。
这对眼睛来说并不容易,并且可能会让用户感到惊讶/困惑。

是否可以让窗口平滑过渡到新的窗口尺寸?
(本质上是动画)

(例如,一个非常可怕的方法是连续调用调整大小,每次都稍微增加窗口大小以逃避过渡)

窗口大小无法为用户调整,因此当窗口扩展时缩小到不同的尺寸,我知道它们的确切尺寸。我还知道我的所有用户都运行 Windows 7(因为我的用户是平板电脑项目中的同学)。

有谁知道 PyQt4 是否可以实现这一点,以及如何实现它?
(Qt Kinetic 听起来与我相关,但事实证明很难搜索适当的信息)

谢谢! x 100

规格:
- PyQt4
- Python 2.7
- Windows 7

When a User opens a particular tab inside the QMainWindow of my PyQt4 driven GUI,
the window needs to be automatically resized so that the contents of this particular tab will fit.

As you know, when using Qwidget.resize(), the Window (by default on PC) is instantly resized.
This isn't easy on the eyes and would probably surprise / confuse the User.

Is it possible to have the window smoothly transition into the new window size?
(An animation in essence)

(For instance, a really horrible method would be to continuously call resize, each time slightly increasing the window size to elude to a transition)

The window size is not adjustable to the User, so when the window exands and shrinks to and from the different sizes, I know their exact dimensions. It is also known to me that all my Users run Windows 7 (Since my users are school mates in a tablet program).

Does anybody know if this is possible with PyQt4, and how to achieve it?
(Qt Kinetic sounded relevant to me, but it's proven difficult to search for the appropriate information)

Thanks! x 100

Specs:
- PyQt4
- Python 2.7
- Windows 7

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩心态 2024-12-27 20:09:34

QPropertyAnimation 可用于对 QObject 属性进行动画处理,包括动画的大小窗户。

我不确定它是否会在性能方面发挥良好作用,因为正如您所说,它会永久调用 resize() ,但这似乎就是您想要的。

您可能会做的是调整窗口大小,但在动画期间以某种方式禁用绘画(即覆盖paint()),以便只有框架平滑地调整大小(应该没问题)并且内部是在达到目标大小之前不会重新绘制。

There is QPropertyAnimation which can be used to animate QObject properties, including the size of your window.

I'm not sure if it will work well performance wise, since it will call resize() perpetually, as you say, but it seems like that is what you want.

What you could maybe do is to resize the window, but somehow disable painting (i.e. override paint()) during that animation, so that only the frame is smoothly resized (should be ok) and the interior is not redrawn until the target size has been reached.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文