Qt QWidget控件透明动画实现
作者:互联网
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
标签:控件,Qt,动画,QPropertyAnimation,pOpacityAnimation1,QWidget,QGraphicsOpacityEffect,pG 来源: https://www.cnblogs.com/qq702368956/p/11332429.html