2014-09-22 1 views
-2

사용자가 클릭하여 대화 상자를 표시 할 때 작은 크기에서 최대 크기로 나오는 대화 상자와 같은 효과를 추가 할 수있는 방법이 있습니까? 대화창을 열 것을 요청할 때 iphoto를 좋아한다면 같은 방법으로 나옵니다 !!! 내가 사용하고있는 코드는 다음과 같습니다show/hide 중에 QTDialog에서 효과를 추가하는 방법은 무엇입니까?

fade_effect = new QGraphicsOpacityEffect(this); 
     this->setGraphicsEffect(fade_effect); 
     animation = new QPropertyAnimation(fade_effect, "opacity"); 
     animation->setEasingCurve(QEasingCurve::InOutQuad); 
     animation->setDuration(5000); 
     animation->setStartValue(1); 
     animation->setEndValue(0.01); 
     animation->start(QPropertyAnimation::DeleteWhenStopped); 
     this->setWindowOpacity(0.5); 
     //this->hide(); 
    //QDialog::reject(); 

그것의이 사건을 숨기고에서 작동하지 않습니다.

+3

['QPropertyAnimation'] (http://qt-project.org/doc/qt-4.8/qpropertyanimation.html)을 위해 일한다면 참조 당신. – thuga

+0

추가 한 코드 예제는 사용자가 요청한 내용에 대해 논란의 여지가 있습니다. 다른 정보를 얻으려면 새 질문을하십시오. – Ezee

답변

1

Qt Animation Framework은 애니메이션 효과를 만드는 데 많은 도구를 제공합니다. 다음은 QPropetyAnimation 당신의 목표를 달성 할 수있는 방법 예입니다

void YourWindowClass::showEvent(QShowEvent* e) 
{ 
//create animation for "geometry" property 
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry"); 

//duration in ms 
animation->setDuration(500); 

//starting geometry 
QRect startRect(900,500,100,100); 

//final geometry 
QRect endRect(750,350,400,400); 

animation->setStartValue(startRect); 
animation->setEndValue(endRect); 

//starts animation which will be deleted when finished 
animation->start(QAbstractAnimation::DeleteWhenStopped); 
} 
+0

안녕하세요, 위의 코드를보십시오. 작동하지 않습니다. – user2098173

+0

exacly가 작동하지 않는 이유는 무엇입니까? 게시하기 전에이 코드를 확인했습니다. – Ezee

+0

귀하의 예제는 불투명도를 변경하는 것이 아니라 위젯을 이동하는 것입니다. –

관련 문제