PyQt4 - 平滑的窗口调整大小转换? [英] PyQt4 - Smooth window resize transition?

查看:69
本文介绍了PyQt4 - 平滑的窗口调整大小转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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)

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

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

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

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).

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

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)

谢谢!× 100

规格:
- PyQt4
- Python 2.7
- 视窗 7

Specs:
- PyQt4
- Python 2.7
- Windows 7

推荐答案

QPropertyAnimation 可用于为 QObject 属性设置动画,包括窗口的大小.

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

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

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.

您可以做的是调整窗口大小,但在该动画期间以某种方式禁用绘画(即覆盖 paint()),以便仅平滑调整帧大小(应该没问题)和在达到目标尺寸之前,不会重新绘制内部.

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.

这篇关于PyQt4 - 平滑的窗口调整大小转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆