Wrong visual display of QPropertyAnimation

33 Views Asked by At

I decided to animate my application in Qt 6.4.0, for this I use QPropertyAnimation and QGraphicsOpacityEffect. But when overlaying, a failure occurs and the elements visually shift. And the buttons themselves remain in place. The effect appears after 1 page change QStackedWidget. Before: enter image description here After: enter image description here QPropertyAnimation implementation:

void MainWindow::animationopacity()
{
    QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this);
    ui->stackedWidgetMenu->setGraphicsEffect(eff);
    QPropertyAnimation *a = new QPropertyAnimation(eff,"opacity");
    a->setDuration(350);
    a->setStartValue(0);
    a->setEndValue(1);
    a->setEasingCurve(QEasingCurve::InBack);
    a->start(QPropertyAnimation::DeleteWhenStopped);
}

This function is called after each click of QPushButton in the menu

void MainWindow::on_pushButtonAnalytics_clicked()
{
    ui->stackedWidgetMenu->setCurrentIndex(1);
    animationopacity();
}

I tried to change layers and shapes, apply eff to other elements, the behavior does not change.

0

There are 0 best solutions below