QWidget控件透明动画实现
要做子控件透明需要用到QGraphicsOpacityEffect类
使用例子如下代码:
QGraphicsOpacityEffect * m_pGraphicsOpacityEffect1; QPropertyAnimation * m_pOpacityAnimation1; m_pGraphicsOpacityEffect1 = new QGraphicsOpacityEffect(m_pHomeBtn); m_pGraphicsOpacityEffect1->setOpacity(1.0); m_pHomeBtn->setGraphicsEffect(m_pGraphicsOpacityEffect1); m_pOpacityAnimation1 = new QPropertyAnimation(m_pGraphicsOpacityEffect1,"opacity",this); m_pOpacityAnimation1->setDuration(m_nDuring); m_pOpacityAnimation1->setStartValue(0); m_pOpacityAnimation1->setEndValue(1.0); m_pOpacityAnimation1->start();
QPropertyAnimation调用start可以设置 动画完成后自动delete
原文地址:https://www.cnblogs.com/qq702368956/p/11332429.html
时间: 2024-11-15 12:38:11