PyQt4 - Smooth window resize transition?

久未见 提交于 2020-01-17 01:20:13

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/8485746/pyqt4-smooth-window-resize-transition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!