2012-07-11 18 views
6

Tengo el siguiente problema: quiero cambiar el tamaño de una ventana usando QPropertyAnimation, para que se vea bien, pero la ventana también se mueve instantáneamente mientras se realiza el cambio de tamaño, mientras que yo no quiero, solo quiero cambiar el tamaño de la ventana y no alterar su valor de posición.Cambiar el tamaño de la ventana usando QPropertyAnimation

tanto, aquí está mi código:

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

en anchura y window_height_min y expand_general_to son mis propias variables para manipular la cantidad de cambio de tamaño de la que se tiene que hacer. PERO, preferences :: x() y preferences :: y() realmente manejan la posición de mi ventana, entonces ¿por qué se mueve, mientras que prefereces :: x() será la misma las dos veces? (en el comienzo y en el valor final)?

¡Gracias de antemano por cualquier respuesta!

Respuesta

8

Por favor intente establecer propiedad en tamaño.

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