6

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

だから、ここに私のコードがあります:

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();

width と window_height_min と expand_general_to は、実行する必要があるサイズ変更の量を処理する独自の変数です。しかし、設定::x() と設定::y() は本当に私のウィンドウの位置を処理します。(開始値と終了値で) ?

ご回答ありがとうございます。

4

1 に答える 1

8

size プロパティを設定してみてください。

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();
于 2012-07-12T04:20:34.727 に答える