2012-07-11 11 views
6

次の問題があります。QPropertyAnimationを使用してウィンドウのサイズを変更して見栄えを良くしたいのですが、サイズ変更中にウィンドウが瞬時に移動します。ウィンドウのサイズを変更し、その位置の値を変更しないだけです。QPropertyAnimationを使用してウィンドウのサイズを変更する

だから、ここに私のコードです:幅とwindow_height_minとexpand_general_toを行う必要がありますサイズ変更の量を扱う私自身の変数です

animation = new QPropertyAnimation(this, "geometry"); 
animation->setDuration(150); 
animation->setStartValue(QRect(preferences::x(), preferences::y(), width, window_height_min)); 
animation->setEndValue(QRect(preferences::x(), preferences::y(), width, window_height_min+expand_general_to)); 
animation->start(); 

。しかし、preferences :: x()とpreferences :: y()は本当に私のウィンドウの位置を扱うので、なぜ動くのですか?prefereces :: x()は同じ時間になりますか? (開始時と終了時の値)?

ありがとうございました!

答えて

8

サイズプロパティを設定してください。

animation = new QPropertyAnimation(this, "size"); 
animation->setDuration(150); 
animation->setStartValue(QSize(width, window_height_min)); 
animation->setEndValue(QSize(width, window_height_min+expand_general_to)); 
animation->start(); 
関連する問題