0
我在學習Qt框架。我的QStateMachine代碼執行正確的操作(按下按鈕使聊天窗口彈出更改大小)。 我無法改變動畫的速度以獲得漂亮的視覺過渡。 有什麼建議嗎?如何設置Qt QStateMachine動畫持續時間
下面的代碼:
MainWindow::MainWindow()
{
widget.setupUi(this);
// chat window - Chat button opens
ChatWindowClosedState = new QState();
ChatWindowOpenState = new QState();
ChatWindowOpenGeometry = widget.groupBox->geometry();
ChatWindowClosedGeometry = widget.pushButton->geometry();
ChatWindowClosedGeometry.translate(-ChatWindowClosedGeometry.width(), 0);
ChatWindowClosedState->assignProperty(widget.groupBox, "geometry", ChatWindowClosedGeometry);
ChatWindowOpenState->assignProperty(widget.groupBox, "geometry", ChatWindowOpenGeometry);
ChatWindowCloseTransition = ChatWindowClosedState->addTransition(widget.pushButton, SIGNAL(clicked()), ChatWindowOpenState);
ChatWindowCloseAnimation = new QPropertyAnimation(widget.pushButton, "geometry");
ChatWindowCloseAnimation->setDuration(5000);
ChatWindowCloseTransition->addAnimation(ChatWindowCloseAnimation);
ChatWindowOpenTransition = ChatWindowOpenState->addTransition(widget.pushButton, SIGNAL(clicked()), ChatWindowClosedState);
ChatWindowOpenAnimation = new QPropertyAnimation(widget.pushButton, "geometry");
ChatWindowOpenAnimation->setDuration(5000);
ChatWindowOpenTransition->addAnimation(ChatWindowOpenAnimation);
machine = new QStateMachine(this);
machine->addState(ChatWindowClosedState);
machine->addState(ChatWindowOpenState);
machine->setInitialState(ChatWindowClosedState);
machine->start();
}