Qt 設置窗體或控件漸變消失

1、主窗體漸變

        QPropertyAnimation *animation =
        new QPropertyAnimation(this,"windowOpacity");
        animation->setDuration(500);
        animation->setStartValue(1);
        animation->setEndValue(0);
        animation->setEasingCurve(QEasingCurve::Linear);
        animation->start();
        connect(animation, SIGNAL(finished()), this, SLOT(showlogout()));

2、子控件漸變

    QGraphicsOpacityEffect *m_pGraphicsOpacityEffect =
    new QGraphicsOpacityEffect(ui->groupBox_login);
    m_pGraphicsOpacityEffect->setOpacity(1.0);
    ui->groupBox_login->setGraphicsEffect(m_pGraphicsOpacityEffect);
    
   QPropertyAnimation *animation =
   new QPropertyAnimation(m_pGraphicsOpacityEffect,"opacity",ui->groupBox_login);
   animation->setDuration(500);
   animation->setStartValue(1);
   animation->setEndValue(0);
   animation->setEasingCurve(QEasingCurve::Linear);
   animation->start();
   connect(animation, SIGNAL(finished()), this, SLOT(showlogout()));

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章