NullPointer
11th September 2011, 22:43
Hi all,
I'm trying to animate my QMainWindow subclasses every time them get showed.
For that I wrote the following:
void Loader_mainWindow::showEvent(QShowEvent * ){
ui->centralWidget->hide(); //hide everything inside to improve speed
QPropertyAnimation * pa=new QPropertyAnimation();
pa->setDuration(1000);
pa->setStartValue(QRect(0,0,0,0));
pa->setEndValue(QRect(100,100,500,350));
pa->setTargetObject(this);
pa->setPropertyName("geometry");
QPropertyAnimation * pb0=new QPropertyAnimation(ui->centralWidget, "visible"); //this animation shows the centralWidget
pb0->setStartValue(false);
pb0->setEndValue(true);
pb0->setDuration(10);
QPropertyAnimation *pb=new QPropertyAnimation(); //and this one gives me a fade in effect
pb->setDuration(1000);
pb->setStartValue(0.0f);
pb->setEndValue(1.0f);
pb->setTargetObject(ui->centralWidget);
pb->setPropertyName("windowOpacity");
QSequentialAnimationGroup *ag=new QSequentialAnimationGroup();
ag->addAnimation(pa);
ag->addAnimation(pb0);
ag->addAnimation(pb);
ag->setLoopCount(2);
ag->start();
}
Happens that only the first animation seems to get executed, the centralWidget is not showed and there is no fade in for the controls...
This code doesn't give me any error code (all properties are ok). And if I remove de pb0 animation, the fade doesn't happen too.
What is wrong??
Thanks in advance.
I'm trying to animate my QMainWindow subclasses every time them get showed.
For that I wrote the following:
void Loader_mainWindow::showEvent(QShowEvent * ){
ui->centralWidget->hide(); //hide everything inside to improve speed
QPropertyAnimation * pa=new QPropertyAnimation();
pa->setDuration(1000);
pa->setStartValue(QRect(0,0,0,0));
pa->setEndValue(QRect(100,100,500,350));
pa->setTargetObject(this);
pa->setPropertyName("geometry");
QPropertyAnimation * pb0=new QPropertyAnimation(ui->centralWidget, "visible"); //this animation shows the centralWidget
pb0->setStartValue(false);
pb0->setEndValue(true);
pb0->setDuration(10);
QPropertyAnimation *pb=new QPropertyAnimation(); //and this one gives me a fade in effect
pb->setDuration(1000);
pb->setStartValue(0.0f);
pb->setEndValue(1.0f);
pb->setTargetObject(ui->centralWidget);
pb->setPropertyName("windowOpacity");
QSequentialAnimationGroup *ag=new QSequentialAnimationGroup();
ag->addAnimation(pa);
ag->addAnimation(pb0);
ag->addAnimation(pb);
ag->setLoopCount(2);
ag->start();
}
Happens that only the first animation seems to get executed, the centralWidget is not showed and there is no fade in for the controls...
This code doesn't give me any error code (all properties are ok). And if I remove de pb0 animation, the fade doesn't happen too.
What is wrong??
Thanks in advance.