Resize a window using QPropertyAnimation

I have the following problem: I want to resize the window using QPropertyAnimation to look beautiful, but the window also moves instantly when resizing occurs, while I don't want this, I just want to resize the window and not change its value position.

So here is 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 size of the resizing to be done. BUT, preferences :: x () and preferences :: y () really handle the position of my window, so why does it move and prefereces :: x () will be the same in both cases? (at the beginning and at the end of the value)?

Thanks in advance for any answers!

+6
source share
1 answer

Try setting the 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(); 
+8
source

Source: https://habr.com/ru/post/920269/


All Articles