我想你可以通過使用動畫處理小部件幾何屬性的QPropertyAnimation來得到你想要的。 但恕我直言,這是窗口管理員的角色來做你想做的。也許你會有一些麻煩繞過它(但我可能是錯的)。
在更好地閱讀您的問題後,您似乎希望使用自己的組件來觸發隱藏/顯示,因此WM不應該成爲問題。
如這裏開始是一些代碼,動畫的小工具的最小化(假設tbw
是要進行動畫處理的小部件的一個實例):
formerGeometry = QtCore.QRect(tbw.geometry()) # storing previous geometry in order to be able to restore it later
hideAnimation = QtCore.QPropertyAnimation(tbw, "geometry")
hideAnimation.setDuration(2000) # chose the value that fits you
hideAnimation.setStartValue(formerGeometry)
#computing final geometry
endTopLeftCorner = QtCore.QPoint(tbw.pos() + QtCore.QPoint(0, tbw.height()))
finalGeometry = QtCore.QRect(endTopLeftCorner, QtCore.QSize(tbw.width(), 0))
hideAnimation.setEndValue(finalGeometry)
hideAnimation.start()
謝謝:) 1,例如在C,我無法讀取,但會嘗試2.如果我的動畫涉及整個窗口,我可以想象WM會照顧它。但是由於動畫涉及一個小部件,那麼你是否仍然會這麼想?如果是的話,你會如何建議這樣做? (注意:目標平臺是Linux)。 – Benjamin
我已更新我的回答 – Jeannot
非常好,謝謝。我會盡力實現這一點。我已經接受了答案 - 假設這可以正常工作:)乾杯。 – Benjamin