A Brief Introduction to the qtimeline class

Source: Internet
Author: User

I found an introduction to the qtimeline class on the internet, either by posting the code to myself, or by failing to focus on it. As a coincidence, I encountered this class in my project and wrote it here for the students who needed it.

Because I recently needed to use the animation to trigger the qgraphicsview framework with the time interval, I accidentally found a useful time class qtimeline in QT. Now let's take a look at it.

Qtimeline has a timeline to control time animations and events. When the constructor is passed in, you must specify a millisecond-level parameter to specify its total running time, such as new qtimeline (1000 ), indicates that the total running time is 1 second.

The second step is to set the number of animation frames for the qtimeline timeline. I believe that people who know the animation should be familiar with the number of frames, people you don't know can think of as much static images as I think of as an animated representation, so for qtimeline: setframerange (0,100 ). It indicates that the animation consists of a total of 100 static images. At the same time, please note that there is a time parameter when the constructor is passed in. Do not think that frame and time have an inevitable relationship, in fact, after a long time or a short time, I can finish the whole 100 frames, but when I finish, the time will affect the number of frames. For example, if your time is set to 0 ms, but the number of frames is 100, after you click Start, the system will immediately reach 100 frames (a 40 ms frame is specified by default in QT, that is, a maximum of 25 frames can be taken in one second, but if you set 0 ms, QT will follow the speed of 40 ms by default). If you set 80 ms, according to qt's habits, it is actually to give you two frame-taking opportunities. Smart people should have guessed that there are 50 and 100 frames.

Step 3, you can set your time transformation curve, that is, the setcurveshape function, to specify whether your time is fast first, slow first, fast, linear, or positive cosine, linearcurve linear transformation is commonly used.

Step 4: Actually, it's almost the same here. When you connect to its framechanged (INT) function with connect, set your own response time slot, you can trigger start to complete the animation effect.

PS: Some people may ask what the setupdateinterval function is for. In fact, you can simply understand that when the timeline goes, the framechanged signal is continuously sent, this update checks the amount of time it sends, but the two do not conflict.

Use the qtimeline class properly to control your own qgraphicsitem animation, enjoy!

A Brief Introduction to the qtimeline class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.