컴퓨터 공학/Qt

[ Qt 프로그래밍 ] 위젯에 애니메이션 사용하기

혼새미로 2015. 11. 26. 23:53
반응형

Colored By Color Scripter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <QPropertyAnimation>
 
Widget::Widget()
{
 
    QPropertyAnimation* animation=new QPropertyAnimation(this,"geometry");
    animation->setDuration(1000); //애니메이션 시간(msec)
    animation->setStartValue(QRect(0,0,this->geometry().width(),this->geometry().height())); //처음 위치와 크기
    animation->setEndValue(QRect(100,100,this->geometry().width(),this->geometry().height())); //종료후 위치와 크기
    animation->setEasingCurve(QEasingCurve::OutBounce);// 변하는 형식
 
    animation->start(); //시작
 
}

 

 

위젯을 상속한 클래스는 QPropertyAnimation 클래스를 사용할 수 있습니다. 이 클래스는 위젯을 이동하거나 크기를 조절할 수 있으며, 변하는 형식도 설정할 수 있습니다.

변하는 형식은 다음 링크에서 알 수 있습니다.

 

http://qt-project.org/doc/qt-4.8/qeasingcurve.html 

 

 

반응형