Friday 15 January 2010

c++ - Qt : how to automate looped slider movement in the background? -



c++ - Qt : how to automate looped slider movement in the background? -

what's straightforward approach have slider move in loop @ given speed when button pressed? i'm guessing involves forking thread sends appropriate signals periodically slider. there canonical approach illustration doing this?

i suggest utilize qpropertyanimation job. set start value, end value , curve want value change

qpropertyanimation *animation = new qpropertyanimation(slider,"sliderposition"); //set duration (how long animation should run - alter value faster when shorter) animation->setduration(1000); //set start value - in case check if value in range of slider animation->setstartvalue(slider->minimum()); //same start value animation->setendvalue(slider->maximum()); //easingcurve defines if goes straight or bouncing n stuff animation->seteasingcurve(qeasingcurve::outcubic); // coyote mentioned, can loop animation (credit him ;)) // -1 defines run forever animation->setloopcount(loopcount) animation->start();

c++ qt

No comments:

Post a Comment