superpacko
20th July 2011, 15:44
We have a mainwindow class that inherits from QMainWindow. We use this flags:
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
Before starting the aplication we display a QDialog with some text. If we create this QDialog with the mainwindow as the parent, some weird things happen when animating de mainwindow.
At some point in the program we need to expand down the mainwindow to show a progressbar. When doing this, misteriously the mainwindow gets expanded down, but it also losses width. Each time we expand it down, the width decreses. This behaviour ONLY happens when creating the QDialog with mainwindow as parent, if using parent NULL, evertyhing works fine.
QDialog* eulaWin = new QDialog(this, Qt::Dialog | Qt::Window | Qt::WindowStaysOnTopHint );
and this is the expand method in the custom utility class for animations:
(expand down => FX_DOWN)
void FXManager::expand(QWidget *widget, int direction, int speed, int ratio, QEasingCurve easingCurve)
{
QPropertyAnimation* animationFrame = new QPropertyAnimation(widget, "geometry", widget);
animationFrame->setDuration(speed);
animationFrame->setEasingCurve(easingCurve);
animationFrame->setStartValue(QRect(widget->geometry().x(),widget->geometry().y(), widget->geometry().width(), widget->geometry().height()));
switch(direction)
{
case (int)FX_LEFT: animationFrame->setEndValue(QRect(widget->geometry().x() - ratio,widget->geometry().y()+0, widget->geometry().width() + ratio, widget->geometry().height()));
break;
case (int)FX_RIGHT: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y()+0, widget->geometry().width() + ratio, widget->geometry().height()));
break;
case (int)FX_UP: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y() - ratio, widget->geometry().width(), widget->geometry().height() + ratio));
break;
case (int)FX_DOWN: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y()+0, widget->geometry().width(), widget->geometry().height() + ratio));
break;
}
animationFrame->start(QPropertyAnimation::DeleteWhenStopped);
widget->repaint();
QApplication::processEvents();
}
The basic idea if the expand method is to expand down (or in any direction choosed) as many pixels as specified in the ratio param. Thus we maintain the original position and width.
Any ideas why this could be happening?
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
Before starting the aplication we display a QDialog with some text. If we create this QDialog with the mainwindow as the parent, some weird things happen when animating de mainwindow.
At some point in the program we need to expand down the mainwindow to show a progressbar. When doing this, misteriously the mainwindow gets expanded down, but it also losses width. Each time we expand it down, the width decreses. This behaviour ONLY happens when creating the QDialog with mainwindow as parent, if using parent NULL, evertyhing works fine.
QDialog* eulaWin = new QDialog(this, Qt::Dialog | Qt::Window | Qt::WindowStaysOnTopHint );
and this is the expand method in the custom utility class for animations:
(expand down => FX_DOWN)
void FXManager::expand(QWidget *widget, int direction, int speed, int ratio, QEasingCurve easingCurve)
{
QPropertyAnimation* animationFrame = new QPropertyAnimation(widget, "geometry", widget);
animationFrame->setDuration(speed);
animationFrame->setEasingCurve(easingCurve);
animationFrame->setStartValue(QRect(widget->geometry().x(),widget->geometry().y(), widget->geometry().width(), widget->geometry().height()));
switch(direction)
{
case (int)FX_LEFT: animationFrame->setEndValue(QRect(widget->geometry().x() - ratio,widget->geometry().y()+0, widget->geometry().width() + ratio, widget->geometry().height()));
break;
case (int)FX_RIGHT: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y()+0, widget->geometry().width() + ratio, widget->geometry().height()));
break;
case (int)FX_UP: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y() - ratio, widget->geometry().width(), widget->geometry().height() + ratio));
break;
case (int)FX_DOWN: animationFrame->setEndValue(QRect(widget->geometry().x()+0,widget->geometry().y()+0, widget->geometry().width(), widget->geometry().height() + ratio));
break;
}
animationFrame->start(QPropertyAnimation::DeleteWhenStopped);
widget->repaint();
QApplication::processEvents();
}
The basic idea if the expand method is to expand down (or in any direction choosed) as many pixels as specified in the ratio param. Thus we maintain the original position and width.
Any ideas why this could be happening?