[PyQt] Help with QStateMachine and animations
Demetrius Cassidy
dcassidy36 at gmail.com
Wed Apr 6 18:30:18 BST 2011
Actually I found out you can add this to a QAbstractTransition, but it does
not make a difference. It seems that the animation which moves widgets
off-screen does not play. I only see the widgets moving on-screen.
slightly modified code:
def _createAnimations(self):
self._stateProceeding = QState()
self._stateReleased = QState()
self._stateMachine = QStateMachine()
self._rtpAnimation = QPropertyAnimation(self.pageRTP, "pos")
self._queueAnimation = QPropertyAnimation(self.pageQueue, "pos")
self._rtpAnimation.setEasingCurve(QtCore.QEasingCurve.InOutCubic)
self._queueAnimation.setEasingCurve(QtCore.QEasingCurve.InOutCubic)
self._rtpAnimation.setDuration(600)
self._queueAnimation.setDuration(self._rtpAnimation.duration())
transition = self._stateProceeding.addTransition(self.callReleased,
self._stateReleased)
transition.addAnimation(self._queueAnimation) #move off-screen
transition.addAnimation(self._rtpAnimation) #move on-screen
(works)
transition = self._stateReleased.addTransition(self.callProceeding,
self._stateProceeding)
transition.addAnimation(self._rtpAnimation) #move off-screen
transition.addAnimation(self._queueAnimation) #move on-screen
(works)
#start at 0,0 and move offscreen towards the right
self._stateProceeding.assignProperty(self.pageQueue, "pos",
QPoint(self.pageQueue.width(), self.pageQueue.y()))
#set QStackedWidget index
self._stateProceeding.assignProperty(self.stackedWidget,
"currentIndex", self.stackedWidget.indexOf(self.pageRTP))
#start offscreen from the left and move towards center
self._stateProceeding.assignProperty(self.pageRTP, "pos",
QPoint(0,0))
#start offscreen from the right and move towards center
self._stateReleased.assignProperty(self.pageRTP, "pos",
QPoint(-self.pageRTP.width(), self.pageRTP.y()))
#set QStackedWidget index
self._stateReleased.assignProperty(self.stackedWidget,
"currentIndex", self.stackedWidget.indexOf(self.pageQueue))
#start at 0,0 and move offscreen towards the left
self._stateReleased.assignProperty(self.pageQueue, "pos",
QPoint(0,0))
self._stateMachine.addState(self._stateReleased)
self._stateMachine.addState(self._stateProceeding)
self._stateMachine.setGlobalRestorePolicy(QStateMachine.DontRestoreProperties)
self._stateMachine.setInitialState(self._stateReleased)
self._stateMachine.start()
Demetrius Cassidy wrote:
>
>
> David Boddie wrote:
>>
>> Have you tried setting the animations on the transitions themselves
>> instead
>> of using default animations? Did this make a difference?
>>
>> David
>> _______________________________________________
>> PyQt mailing list PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>
> What do you mean by setting it on the transition? QPropertyAnimation does
> not derive from QAbstractTransition so you can't add it by itself, and I
> don't see a start property =(
>
> Can you expand a bit on this?
>
--
View this message in context: http://old.nabble.com/Help-with-QStateMachine-and-animations-tp31319779p31335459.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt
mailing list