zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    关于Thread ThreadPool Parallel 的一些小测试demo
    VS附加到进程调试
    netcore 实现一个简单的Grpc 服务端和客户端
    CodeSmith 找不到请求的 .Net Framework Data Provider
    ocelot集成consul服务发现
    使用ocelot作为api网关
    关于add migration 报错的问题解决方案
    关于多线程efcore dbcontext 的解决方案。
    docker mysql 容器报too many connections 引发的liunx磁盘扩容操作
    关于liunx 机器脱机环境(netcore)Nuget包迁移的问题
  • 原文地址:https://www.cnblogs.com/wiessharling/p/3569935.html
Copyright © 2011-2022 走看看