首页 > 其他 > 详细

slide from one widget to another

时间:2014-02-27 16:47:43      阅读:529      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QWidget panel;
    QVBoxLayout *l = new QVBoxLayout(&panel);
    QFrame *viewport = new QFrame;
    viewport->setFrameShape(QFrame::Box);
    viewport->setFixedSize(400,600);

    l->addWidget(viewport);
    QPushButton *b = new QPushButton("Swap");
    l->addWidget(b);
    QStateMachine machine;
    QState *s1 = new QState;
    QState *s2 = new QState;

    QWidget *w1 = new QCalendarWidget(viewport);
    w1->setFixedSize(300,500);
    QWidget *w2 = new QListView(viewport);
    w2->setFixedSize(300,500);

    QGraphicsBlurEffect *e1 = new QGraphicsBlurEffect(w1);
    QGraphicsBlurEffect *e2 = new QGraphicsBlurEffect(w2);
    w1->setGraphicsEffect(e1);
    w2->setGraphicsEffect(e2);

    s1->assignProperty(w1, "pos", QPoint(50,50));
    s1->assignProperty(w2, "pos", QPoint(450,50));
    s1->assignProperty(e1, "blurRadius", 0);
    s1->assignProperty(e2, "blurRadius", 15);
    s2->assignProperty(w1, "pos", QPoint(-350, 50));
    s2->assignProperty(w2, "pos", QPoint(50,50));
    s2->assignProperty(e1, "blurRadius", 15);
    s2->assignProperty(e2, "blurRadius", 0);

    s1->addTransition(b, SIGNAL(clicked()), s2);
    s2->addTransition(b, SIGNAL(clicked()), s1);

    machine.addState(s1);
    machine.addState(s2);

    QPropertyAnimation *anim1 = new QPropertyAnimation(w1, "pos");
    QPropertyAnimation *anim2 = new QPropertyAnimation(w2, "pos");
    anim1->setEasingCurve(QEasingCurve::InOutCubic);
    anim2->setEasingCurve(anim1->easingCurve());
    anim1->setDuration(2000);
    anim2->setDuration(anim1->duration());
    machine.addDefaultAnimation(anim1);
    machine.addDefaultAnimation(anim2);

    anim1 = new QPropertyAnimation(e1, "blurRadius");
    anim2 = new QPropertyAnimation(e2, "blurRadius");
    anim1->setDuration(1000);
    anim2->setDuration(anim1->duration());
    machine.addDefaultAnimation(anim1);
    machine.addDefaultAnimation(anim2);
    machine.setInitialState(s1);
    machine.start();
    panel.show();
    return app.exec();
}
bubuko.com,布布扣

slide from one widget to another

bubuko.com,布布扣

bubuko.com,布布扣

slide from one widget to another,布布扣,bubuko.com

slide from one widget to another

原文:http://www.cnblogs.com/wiessharling/p/3569935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!