Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize window using QPropertyAnimation

Tags:

animation

qt

I have the following problem: I want to resize a window using QPropertyAnimation, so as to look nice, but the window also instantly moves while the resizing takes place, while I don't want it to, I just want to resize the window and not to alter its position value.

So, here's my code:

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

where width and window_height_min and expand_general_to are my own variables that handle the amount of the resizing that has to be done. BUT, preferences::x() and preferences::y() truly handle the position of my window, so why it moves, while prefereces::x() will be the same both of the times? (in the start and in the end value) ?

Thanks in advance for any answers!

like image 212
hytromo Avatar asked Jul 11 '12 21:07

hytromo


Video Answer


1 Answers

Please try to set size property.

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();
like image 177
liuyi.luo Avatar answered Oct 12 '22 15:10

liuyi.luo