• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            zhonghua

            C++博客 首頁 新隨筆 聯(lián)系 聚合 管理
              72 Posts :: 1 Stories :: 4 Comments :: 0 Trackbacks

            將動畫們弄到一起


            一個應(yīng)用通常將包含不止一個動畫。例如,你可能想同時移動多個圖形item也可能順序的一個接一個的移動。
            QanimationGroup 的子類們(QSequentialAnimationGroup和QParallelAnimationGroup)是其它動畫的容器,所以這些動畫既可 以并行也可以串行。QAnimationGroup是一個非屬性動畫的例子,但是它定期的收到時間改變的通知。這使得它可以把時間改變傳輸給所包含的動畫 們,從而控制何時播放那些動畫們。

            讓我們看一下使用QSequentialAnimatoinGroup和QParallelAnimationGroup的代碼示例。
            QPushButton *bonnie = new QPushButton("Bonnie");
            bonnie->show();
            QPushButton *clyde = new QPushButton("Clyde");
            clyde->show();
            QPropertyAnimation *anim1 = new QPropertyAnimation(bonnie, "geometry");
            // Set up anim1
            QPropertyAnimation *anim2 = new QPropertyAnimation(clyde, "geometry");
            // Set up anim2
            QParallelAnimationGroup *group = new QParallelAnimationGroup;
            group->addAnimation(anim1);
            group->addAnimation(anim2);
            group->start();
            一個并行g(shù)roup在同一時刻播放多個動畫。對start()的調(diào)用將啟動它所統(tǒng)治的所有的動畫。

            QPushButton button("Animated Button");
            button.show();
            QPropertyAnimation anim1(&button, "geometry");
            anim1.setDuration(3000);
            anim1.setStartValue(QRect(0, 0, 100, 30));
            anim1.setEndValue(QRect(500, 500, 100, 30));
            QPropertyAnimation anim2(&button, "geometry");
            anim2.setDuration(3000);
            anim2.setStartValue(QRect(500, 500, 100, 30));
            anim2.setEndValue(QRect(1000, 500, 100, 30));
            QSequentialAnimationGroup group;
            group.addAnimation(&anim1);
            group.addAnimation(&anim2);
            group.start();
            QsequentialAnimationGroup順序的播放它的動畫們。它在上一個完成時按順序播放下一個。

            既然一個動畫組本就是一個動畫類,你可以把它添加到其它組中。如此,你可以建立起一個動畫樹。


            動畫和狀態(tài)
            當 使用狀態(tài)機,我們可以使用一個QSignalTransition或QEventTransition類在狀態(tài)轉(zhuǎn)換時連接一個或多個動畫。這些類都是從 QAbstractTransition派生的,它們定義了簡易的函數(shù)addAnimation(),使得能夠添加一個或多個動畫,在狀態(tài)轉(zhuǎn)換時啟動這些 動畫。

            我們還可能連接屬性與狀態(tài),而不是手動設(shè)置開始與結(jié)束值。下面是完整的代碼,演示了動畫一個QPushButton的geometry屬性。

            QPushButton *button = new QPushButton("Animated Button");
            button->show();
            QStateMachine *machine = new QStateMachine;
            QState *state1 = new QState(machine);
            state1->assignProperty(button, "geometry", QRect(0, 0, 100, 30));
            machine->setInitialState(state1);
            QState *state2 = new QState(machine);
            state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30));
            QSignalTransition *transition1 = state1->addTransition(button,
            SIGNAL(clicked()), state2);
            transition1->addAnimation(new QPropertyAnimation(button, "geometry"));
            QSignalTransition *transition2 = state2->addTransition(button,
            SIGNAL(clicked()), state1);
            transition2->addAnimation(new QPropertyAnimation(button, "geometry"));
            machine->start();
            posted on 2013-06-05 16:40 米米 閱讀(880) 評論(0)  編輯 收藏 引用 所屬分類: qt
            99久久免费国产精品| 久久精品麻豆日日躁夜夜躁| 88久久精品无码一区二区毛片| 99久久免费只有精品国产| 亚洲国产精品成人久久蜜臀| 午夜不卡久久精品无码免费| 国产亚洲色婷婷久久99精品91| 国产精品亚洲综合久久| 精品国产福利久久久| 久久久久综合中文字幕| 久久w5ww成w人免费| 国产精品日韩欧美久久综合| 欧美亚洲国产精品久久| 99久久婷婷国产一区二区| 亚洲综合日韩久久成人AV| 91久久精品视频| 久久精品国产久精国产思思 | 精品伊人久久大线蕉色首页| 97r久久精品国产99国产精| 久久99国产精品久久99小说| 国产AV影片久久久久久| 97久久精品午夜一区二区| 理论片午午伦夜理片久久 | 国产真实乱对白精彩久久| 亚洲国产精品久久久天堂| 亚洲综合久久夜AV | 久久久精品国产亚洲成人满18免费网站 | 亚洲人成精品久久久久| 久久一区二区三区99| 国内精品伊人久久久久影院对白 | 久久精品三级视频| 91精品国产高清久久久久久91| 日本人妻丰满熟妇久久久久久| 精品无码久久久久国产动漫3d| 亚洲国产日韩欧美综合久久| 久久久久人妻一区精品果冻| 精品久久久久久无码国产| 久久99精品国产99久久6| 久久婷婷色综合一区二区| 久久久精品国产Sm最大网站| 久久久99精品成人片中文字幕|