• slide from one widget to another


    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();
    }

    slide from one widget to another

  • 相关阅读:
    HDU2546(01背包)
    HDU4283(KB22-G)
    POJ1651(KB-E)
    POJ2955(KB22-C 区间DP)
    POJ3264(KB7-G RMQ)
    POJ3468(KB7-C 线段树)
    POJ3616(KB12-R dp)
    Ubuntu16.04安装opencv for python/c++
    华中农业大学第五届程序设计大赛网络同步赛-L
    华中农业大学第五届程序设计大赛网络同步赛-K
  • 原文地址:https://www.cnblogs.com/wiessharling/p/3569935.html
Copyright © 2020-2023  润新知