• 6150阅读
  • 4回复

[提问]关于animation的问题(闪烁) [复制链接]

上一主题 下一主题
离线amateuryy
 

只看楼主 倒序阅读 楼主  发表于: 2011-04-23
想做一个点击按钮more,动画的逐渐增加THIS窗口的高度,并逐渐把之前hide的THIS中的GROUP窗口显示出来的效果
void Calculator::showGrpOprator(bool istoggled)

{

    QPropertyAnimation *animUi = new QPropertyAnimation(this,

                                                        "size");

    if ( istoggled ) {

        ui->groupBox_Operators->show();

        animUi->setDuration(1000);

        animUi->setStartValue(this->size());

        this->resize(Width0, Height1);

        animUi->setEndValue(this->size());

        animUi->setEasingCurve(QEasingCurve::OutBounce);

        animUi->start(QAbstractAnimation::DeleteWhenStopped);

    }else {

        connect(animUi, SIGNAL(finished()), ui->groupBox_Operators,

                SLOT(hide()));

        animUi->setDuration(1000);

        animUi->setStartValue(this->size());

        this->resize(Width0, Height0);

        animUi->setEndValue(this->size());

        animUi->setEasingCurve(QEasingCurve::OutBounce);

        animUi->start(QAbstractAnimation::DeleteWhenStopped);

    }

}
但是存在闪烁的问题,就是最开始已经把边框show了一下,然后窗口再从当前长度逐渐增长,同样收回的时候也会有闪烁的现象
请问有什么办法可以消除闪烁呢,得到我想要的效果?
谢谢~~~
离线downstairs

只看该作者 1楼 发表于: 2011-04-24
qtimer
喜爱编程的猫头鹰
离线amateuryy

只看该作者 2楼 发表于: 2011-04-24
自己解决了,,,,原来是RESIZE的问题
animUi->setStartValue(this->size());

        this->resize(Width0, Height0);

        animUi->setEndValue(this->size());

改成
  animUi->setStartValue(this->size());
        QSize *size = new QSize(Width0, Height0);
        animUi->setEndValue(*size);
就不会出现闪烁的情况了。。。。
[ 此帖被amateuryy在2011-04-24 16:58重新编辑 ]
离线roywillow

只看该作者 3楼 发表于: 2011-04-24
可是那么声明……最后别忘了delete啊
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线amateuryy

只看该作者 4楼 发表于: 2011-04-24
回 3楼(roywillow) 的帖子
嗯,谢谢提醒。。。。
快速回复
限100 字节
 
上一个 下一个