tags:

views:

95

answers:

2

Hi , i have a problem with QPropertyAnimation in Qt

my code:

QString my_text = "Hello Animation";
        ui->textBrowser->setText((quote_text));
        ui->textBrowser->show();
        QPropertyAnimation animation2(ui->textBrowser,"geometry");
        animation2.setDuration(1000);
        animation2.setStartValue(QRect(10,220/4,1,1));
        animation2.setEndValue(QRect(10,220,201,71));
        animation2.setEasingCurve(QEasingCurve::OutBounce);
        animation2.start();

till now it seems very good , but the problem is that i can see this animation only when i show a message box after it .

        QMessageBox m;
        m.setGeometry(QRect(100,180,100,50));
        m.setText("close quote");
        m.show();
        m.exec();

when i remove the code of this message box , i can't see the animation anymore. the functionality of the program doesn't require showing this MessageBox at all. Can anybody help?

A: 

Maybe it is an update problem. Could you try to connect the valueChanged() signal of QPropertyAnimation to an update() call in the GUI?

Vicken Simonian
A: 

My guess is that the code for the animation that you present is inside a larger chunk of code where the control doesn't get back to the event loop (or the event loop hasn't started yet). This means that when the MessageBox's exec function is called, an event loop starts operating again, and the animation starts. If you were to dismiss the message box in the middle of the animation, it would probably freeze at that point, as well.

Caleb Huitt - cjhuitt
@Caleb Huitt: yes , that's what happens exactlyany solutions suggested ?
@belhaouary: You will need to either start the regular app processing before this point (if you haven't), or make it so your function doesn't block processing of events (if you've started event processing). For the second option, you can either break things up and use timers with a timeout of 0 ms, or you can move the heavy processing into another thread.
Caleb Huitt - cjhuitt