PDA

View Full Version : How to move an animated(in motion) QPushButton above/over a static QPushButton.



rishiraj
22nd February 2010, 09:30
Hi,
I was trying the animation examples given in the Qt docs. This is the code which I used-



#include <QtCore>
#include <QApplication>
#include <QtGui>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton *button1=new QPushButton("Animated");
button1->show();
QPushButton *button2 = new QPushButton("Not animated");
button2->setGeometry(50, 50, 100, 30);
button2->show();
QPropertyAnimation animation(button1, "geometry");
animation.setDuration(5000);
animation.setKeyValueAt(0, QRect(0, 0, 100, 30));
animation.setKeyValueAt(0.1, QRect(150, 150, 100, 30));
animation.setKeyValueAt(1, QRect(0, 0, 100, 30));
animation.setEasingCurve(QEasingCurve::OutBounce);
animation.start();
return a.exec();
}


It works fine but, the "Animated" button passes under/below the "Not animated" button when I execute the code.I would prefer that the "Animated" button passes over/above the "Not animated" button.Is there any simple way of doing that?
Please advice.

Thank you.