<div>I am trying to animate a QTableView moving off-screen from center (0,0), which is replaced by a QGroupBox which slides to 0,0 from off-screen inside my QStackedWidget. </div><div><br></div><div>I am using a QStateMachine which contains two states, and basically when the state 'stateProceeding' is entered, only the QGroupBox is animated - the QTableView just seems to flash once, then the QStackedWidget index is changed and QGroupBox is animated. Similarly, when it enters the stateReleased state, the opposite happens - QTableView is animated, but not the QGroupBox. </div>
<div><br></div><div>What am I doing wrong? I want these widgets to smoothly animate sliding on and off-screen depending on the event.</div><div><br></div><div>each page is the QWidget page contained inside the QStackedWidget</div>
<div>self.pageQueue contains a QTableView<br></div><div>self.pageRTP contains a QGroupBox</div><div><br></div><div>Animation Code:<br></div><div><br></div><div>def _createAnimations(self):<div style="margin-left: 40px"> self._stateProceeding = QState()</div>
<div style="margin-left: 40px"> self._stateReleased = QState()</div><div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"> self._stateMachine = QStateMachine()</div><div style="margin-left: 40px">
<br></div><div style="margin-left: 40px"># when the signal callReleased is emitted while in the state stateProceeding, move to state stateReleased</div><div style="margin-left: 40px"> self._stateProceeding.addTransition(self.callReleased, self._stateReleased)</div>
<div style="margin-left: 40px"><br></div><div style="margin-left: 40px"># reverse of the above</div><div style="margin-left: 40px"> self._stateReleased.addTransition(self.callProceeding, self._stateProceeding)</div>
<div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"> self._rtpAnimation = QPropertyAnimation(self.pageRTP, "pos")</div><div style="margin-left: 40px"> self._queueAnimation = QPropertyAnimation(self.pageQueue, "pos")</div>
<div style="margin-left: 40px"> self._rtpAnimation.setEasingCurve(QtCore.QEasingCurve.InOutCubic)</div><div style="margin-left: 40px">self._queueAnimation.setEasingCurve(QtCore.QEasingCurve.InOutCubic)<br></div><div style="margin-left: 40px">
self._rtpAnimation.setDuration(600)</div><div style="margin-left: 40px"> self._queueAnimation.setDuration(self._rtpAnimation.duration())</div><div style="margin-left: 40px"> <br></div><div style="margin-left: 40px">
<br></div><div style="margin-left: 40px"> #start at 0,0 and move offscreen towards the right</div><div style="margin-left: 40px"> self._stateProceeding.assignProperty(self.pageQueue, "pos", QPoint(self.pageQueue.width(), self.pageQueue.y()))</div>
<div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"> #set QStackedWidget index</div><div style="margin-left: 40px"> self._stateProceeding.assignProperty(self.stackedWidget, "currentIndex", self.stackedWidget.indexOf(self.pageRTP))</div>
<div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"> #start offscreen from the left and move towards center</div><div style="margin-left: 40px"> self._stateProceeding.assignProperty(self.pageRTP, "pos", QPoint(0,0))</div>
<div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"><br></div><div style="margin-left: 40px"> #start at 0,0 and move offscreen towards the left</div><div style="margin-left: 40px"> self._stateReleased.assignProperty(self.pageQueue, "pos", QPoint(0,0))</div>
<div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"> #set QStackedWidget index</div><div style="margin-left: 40px"> self._stateReleased.assignProperty(self.stackedWidget, "currentIndex", self.stackedWidget.indexOf(self.pageQueue))</div>
<div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"> #start offscreen from the right and move towards center</div><div style="margin-left: 40px"> self._stateReleased.assignProperty(self.pageRTP, "pos", QPoint(-self.pageRTP.width(), self.pageRTP.y()))</div>
<div style="margin-left: 40px"> <br></div><div style="margin-left: 40px"><br></div><div style="margin-left: 40px"> self._stateMachine.addState(self._stateReleased)</div><div style="margin-left: 40px"> self._stateMachine.addState(self._stateProceeding)</div>
<div style="margin-left: 40px"> self._stateMachine.addDefaultAnimation(self._queueAnimation)</div><div style="margin-left: 40px"> self._stateMachine.addDefaultAnimation(self._rtpAnimation)</div><div style="margin-left: 40px">
self._stateMachine.setGlobalRestorePolicy(QStateMachine.DontRestoreProperties)</div><div style="margin-left: 40px"> self._stateMachine.setInitialState(self._stateReleased)</div><div style="margin-left: 40px"> self._stateMachine.start()</div>
<div><br></div></div>