Bonjour

Je cherche à faire apparaître un QDialog modal via une animation qui
fait arriver le dialog depuis la gauche (hors visibilité) vers le centre
de l'écran.

J'ai surchargé la méthode showEvent selon le code suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void UiWindow::showEvent(QShowEvent * event) {
 
    QPropertyAnimation* animation = new QPropertyAnimation(this, "pos", this);
    animation->setDuration(2500);
    animation->setEasingCurve(QEasingCurve::InOutBack);
    QRect g= QApplication::desktop()->screenGeometry();
 
    int top = (g.height() - height()) / 2;
    int finalLeft = (g.width() - width()) / 2;
    QPoint posStart(-width(), top);
    QPoint posEnd(finalLeft, top);
    animation->setKeyValueAt(0.0, posStart);
    animation->setKeyValueAt(1.0, posEnd);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
    event->setAccepted(true);
}
Le code appelant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 UiWindow* uiCheckList = new UiWindow();
   if (uiCheckList->exec() == QDialog::Accepted) {}
J'ai trois questions :
- Surcharger showEvent est il la bonne méthode ?
- L'animation ne commence pas hors écran avec le bord gauche du dialogue
aligné sur le bord gauche de l'écran, il semble que mettre -width() dans
posStart ne donne pas l'effet escompté mais le même que si je mettais 0.
Comment faire ?
-L'animation ne se lance pas tout de suite : le dialogue apparait qq centaines
(à l’œil) de miliisecondes puis s'anime. Existe-t-il un paliatif ?

Merci
Henri