[Moved] flickering in frame moving animation



  • Hi guys,

    i try to do this simple animation:

    !http://marcoseverini.net/xweb/question.jpg(Animation sample image)!

    the layout of window is grid (for window autoresize).

    the first animation where frame 1 go out run correctly, but the second animation where frame 2 go inside the window not run correctly... the animation flicker...

    this is the code:
    [where:
    Button 1=ButtonLogin;
    Frame 1= login;
    frame 2= linkedin;]

    @//QWidget_home.cpp

    Home::Home(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Home)
    {
    ui->setupUi(this);
    inizio();
    }

    void Home::inizio()
    {
    databaseOn(); //read data from sql Database
    hideall();
    ui->Login->show(); //show the frame 1

            //set the image and labels in all frame
            QPixmap immagine(":/immagine1.jpg");
            ui->labelimage->setPixmap(immagine);
            QPixmap immaginelogin(":/loginlogo.png");
            ui->labelloginimage->setPixmap(immaginelogin);
            ui->linePassword->setEchoMode(QLineEdit::Password);
            QPixmap immaginewelcome(":/welcome.png");
            ui->labelWelcome->setPixmap(immaginewelcome);
    

    }

    void Home::hideall(){ //hide all
    ui->Login->hide();
    ui->Linkedin->hide();
    ui->ModificaProfilo->hide();
    }

    //[...]

    void Home::on_pushButtonLogin_clicked()
    {

    //convert data in form for the database (is a vector)
    bool logged=true;
    QString * s= new QString[2];
    s[0]=ui->lineUsername->text();
    s[1]=ui->linePassword->text();
    try{
        cercami(s);
    }catch (errori){
        ui->lineUsername->clear();
        ui->linePassword->clear();
        logged=false;
    }
    //try to read data from vector
    
    try {
        scriviProfilo(logged); //try to complete the label of frame linkedin with database information
    } catch (errori) {}
    
    //show frame 2
    showLinkedin();
    

    }

    //[...]

    void Home::showLinkedin() { //hide the frame1

    int dimensioneLarghezza=geometry().width()-24;
    int dimensioneAltezza=geometry().height()-24;
    int dimensioneX=12;//ui->Login->geometry().x();
    int dimensioneY=12;//ui->Login->geometry().y();
    int surplus=geometry().width()-24;
    
    QPropertyAnimation *animation = new QPropertyAnimation(ui->Login, "geometry");
    animation->setDuration(500);
    animation->setStartValue(QRect(dimensioneX,dimensioneY,dimensioneLarghezza ,dimensioneAltezza ));
    animation->setEndValue(QRect(-(dimensioneX+surplus),dimensioneY, dimensioneLarghezza ,dimensioneAltezza));
    animation->setEasingCurve(QEasingCurve::InOutExpo);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
    connect(animation, SIGNAL(finished()), SLOT(hideLoginAnimationEnd())); //when is hide show frame 2
    

    }

    void Home::hideLoginAnimationEnd(){ //show frame 2
    ui->Login->hide();

    ui->Linkedin->show();
    
    qDebug()<<geometry().width();
    qDebug()<<geometry().height();
    int dimensioneLarghezza=geometry().width()-24;
    int dimensioneAltezza=geometry().height()-24;
    int dimensioneX=12;
    int dimensioneY=12;
    int surplus=geometry().width()-24;
    
    
    
    QPropertyAnimation *animation = new QPropertyAnimation(ui->Linkedin, "geometry");
    animation->setDuration(500);
    animation->setStartValue(QRect(dimensioneX+surplus,dimensioneY, dimensioneLarghezza, dimensioneAltezza));
    animation->setEndValue(QRect(dimensioneX,dimensioneY, dimensioneLarghezza, dimensioneAltezza));
    animation->setEasingCurve(QEasingCurve::InOutExpo);
    animation->start();
    

    }@

    There's any way to remove flickering?

    Thanks.



  • Moved to Desktop because it is not about Qt Quick.



  • ok, Thanks :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.