#include <QApplication>
#include <QStateMachine>
#include <QPushButton>
#include <QTextEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QSpacerItem>
#include <QSignalTransition>
#include <QPropertyAnimation>
int main(int argc,char **argv)
{
QApplication app(argc,argv);
QWidget* panel = new QWidget;
panel->resize(320,360);
QVBoxLayout* layout = new QVBoxLayout();
panel->setLayout(layout);
QPushButton* button = new QPushButton("Click");
QSpacerItem* spacer = new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Minimum);
QHBoxLayout* hlayout = new QHBoxLayout();
layout->addLayout(hlayout);
hlayout->addItem(spacer);
hlayout->addWidget(button);
QTextEdit* edit1 = new QTextEdit();
edit1->setGeometry(QRect(10,50,300,300));
QTextEdit* edit2 = new QTextEdit();
edit2->setGeometry(QRect(10,300,300,0));
layout->addWidget(edit1);
layout->addWidget(edit2);
QStateMachine* machine = new QStateMachine;
QState* state1 = new QState(machine);
state1->assignProperty(edit1,"geometry",QRect(10,50,300,300));
state1->assignProperty(edit2,"geometry",QRect(10,300,300,0));
QState* state2 = new QState(machine);
state2->assignProperty(edit1,"geometry",QRect(10,50,300,0));
state2->assignProperty(edit2,"geometry",QRect(10,50,300,300));
machine->setInitialState(state1);
QPropertyAnimation* ani1 = new QPropertyAnimation(edit1,"geometry");
ani1->setDuration(2000);
ani1->setEasingCurve(QEasingCurve::OutBounce);
QPropertyAnimation* ani2 = new QPropertyAnimation(edit2,"geometry");
ani2->setDuration(2000);
ani2->setEasingCurve(QEasingCurve::InOutExpo);
QSignalTransition* transition1 = state1->addTransition(button,SIGNAL(clicked()),state2);
QSignalTransition* transition2 = state2->addTransition(button,SIGNAL(clicked()),state1);
transition1->addAnimation(ani1);
transition1->addAnimation(ani2);
transition2->addAnimation(ani1);
transition2->addAnimation(ani2);
machine->start();
panel->show();
return app.exec();
}