{"id":109923,"date":"2026-09-25T08:32:58","date_gmt":"2026-09-25T00:32:58","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/109923.html"},"modified":"2026-09-25T08:32:58","modified_gmt":"2026-09-25T00:32:58","slug":"qml-lottie%e5%8a%a8%e7%94%bb%ef%bc%9a%e7%b4%a0%e6%9d%90%e7%8b%ac%e7%ab%8b%e6%8e%a7%e5%88%b6%e4%b8%8e%e5%b0%ba%e5%af%b8%e9%80%82%e9%85%8d","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/109923.html","title":{"rendered":"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d"},"content":{"rendered":"<p>\u8fd9\u7bc7\u7528\u4e00\u4e2a\u793a\u4f8b\u628a 4 \u4e2a Lottie \u7d20\u6750\u653e\u5230\u540c\u4e00\u5c4f\u4e0a\u540c\u65f6\u64ad\u653e&#xff0c;\u6f14\u793a\u4e24\u4ef6\u4e8b&#xff1a;\u591a\u8def\u52a8\u753b\u600e\u4e48\u5404\u81ea\u72ec\u7acb\u53c8\u7edf\u4e00\u63a7\u5236&#xff0c;\u4ee5\u53ca LottieAnimation \u90a3\u4e2a\u300c\u5199\u4e86 width \u4e5f\u4e0d\u751f\u6548\u300d\u7684\u5751\u5230\u5e95\u8be5\u600e\u4e48\u89e3\u3002<\/p>\n<p>\u672c\u6587\u662f QML Lottie \u7cfb\u5217\u7b2c 2 \u7bc7&#xff0c;\u5171 3 \u7bc7\u3002<\/p>\n<hr \/>\n<h3>\u52a8\u753b\u5c55\u793a<\/h3>\n<p>4 \u4e2a\u7d20\u6750\u5404\u5360\u4e00\u5f20\u5361\u7247&#xff0c;\u8fdb\u5165\u5373\u540c\u65f6\u64ad\u653e\u3002\u9876\u90e8\u4e00\u6392\u662f\u300c\u5168\u90e8\u64ad\u653e \/ \u5168\u90e8\u6682\u505c\u300d\u548c\u300c\u5168\u90e8\u91cd\u64ad\u300d&#xff0c;\u76f4\u63a5\u70b9\u67d0\u5f20\u5361\u7247\u5219\u53ea\u63a7\u5236\u90a3\u4e00\u8def\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260925003256-6ab5c138d4f72.gif\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<hr \/>\n<h4>\u6f14\u793a\u4ee3\u7801<\/h4>\n<p>import QtQuick<br \/>\nimport QtQuick.Controls<br \/>\nimport QtQuick.Layouts<br \/>\nimport Qt.labs.lottieqt<\/p>\n<p>Rectangle {<br \/>\n    id: root<br \/>\n    color: &#034;#FAFBFC&#034;<\/p>\n<p>    property bool allPlaying: true<\/p>\n<p>    property var cards: [<br \/>\n        { name: &#034;\u5bf9\u52fe\u5706\u73af&#034;, src: &#034;qrc:\/lottie\/success.json&#034; },<br \/>\n        { name: &#034;\u6587\u6863\u626b\u63cf&#034;, src: &#034;qrc:\/lottie\/document-ocr-scan.json&#034; },<br \/>\n        { name: &#034;\u6c99\u6f0f\u52a0\u8f7d&#034;, src: &#034;qrc:\/lottie\/loading-sand-clock_qt.json&#034; },<br \/>\n        { name: &#034;\u5220\u9664\u6587\u4ef6&#034;, src: &#034;qrc:\/lottie\/delete-bin.json&#034; }<br \/>\n    ]<\/p>\n<p>    \/\/ \u7edf\u4e00\u63a7\u5236\u6240\u6709\u5361\u7247&#xff1a;\u5361\u7247\u672c\u8eab\u5bf9\u5916\u66b4\u9732 setPlaying()<br \/>\n    \/\/ \u6ce8\u610f Grid \u53ea\u7ba1\u6446\u653e\u3001\u4e0d\u80fd\u6309\u4e0b\u6807\u53d6\u5b50\u9879&#xff0c;\u8981\u901a\u8fc7 Repeater \u6765\u7d22\u5f15<br \/>\n    function setAll(on) {<br \/>\n        allPlaying &#061; on<br \/>\n        for (var i &#061; 0; i &lt; cardRepeater.count; &#043;&#043;i) {<br \/>\n            var c &#061; cardRepeater.itemAt(i)<br \/>\n            if (c)<br \/>\n                c.setPlaying(on)<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u5355\u5361\u7247\u88ab\u70b9\u4e86\u4e4b\u540e&#xff0c;\u628a\u300c\u5168\u90e8\u64ad\u653e \/ \u5168\u90e8\u6682\u505c\u300d\u7684\u6587\u6848\u540c\u6b65\u8fc7\u6765<br \/>\n    function syncAllPlaying() {<br \/>\n        for (var i &#061; 0; i &lt; cardRepeater.count; &#043;&#043;i) {<br \/>\n            var c &#061; cardRepeater.itemAt(i)<br \/>\n            if (c &amp;&amp; c.playing) {<br \/>\n                allPlaying &#061; true<br \/>\n                return<br \/>\n            }<br \/>\n        }<br \/>\n        allPlaying &#061; false<br \/>\n    }<\/p>\n<p>    ColumnLayout {<br \/>\n        anchors.fill: parent<br \/>\n        anchors.margins: 18<br \/>\n        spacing: 12<\/p>\n<p>        \/\/ &#8230; \u7701\u7565\u9875\u9762\u6807\u9898\u4e0e\u8bf4\u660e\u6587\u6848 &#8230;<\/p>\n<p>        \/\/ \u7edf\u4e00\u63a7\u5236<br \/>\n        RowLayout {<br \/>\n            Layout.fillWidth: true<br \/>\n            spacing: 10<br \/>\n            Button {<br \/>\n                text: root.allPlaying ? &#034;\u5168\u90e8\u6682\u505c&#034; : &#034;\u5168\u90e8\u64ad\u653e&#034;<br \/>\n                implicitHeight: 32<br \/>\n                implicitWidth: 116<br \/>\n                onClicked: root.setAll(!root.allPlaying)<br \/>\n            }<br \/>\n            Button {<br \/>\n                text: &#034;\u5168\u90e8\u91cd\u64ad&#034;<br \/>\n                implicitHeight: 32<br \/>\n                onClicked: {<br \/>\n                    root.setAll(true)<br \/>\n                    for (var i &#061; 0; i &lt; cardRepeater.count; &#043;&#043;i) {<br \/>\n                        var c &#061; cardRepeater.itemAt(i)<br \/>\n                        if (!c)<br \/>\n                            continue<br \/>\n                        var a &#061; c.childAnim()<br \/>\n                        a.gotoAndPlay(a.startFrame)<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n            Item { Layout.fillWidth: true }<br \/>\n            Label {<br \/>\n                text: &#034;\u70b9\u5361\u7247\u53ef\u5355\u72ec\u6682\u505c\u67d0\u4e00\u8def&#034;<br \/>\n                color: &#034;#999&#034;<br \/>\n                font.pixelSize: 11<br \/>\n            }<br \/>\n        }<\/p>\n<p>        Grid {<br \/>\n            id: grid<br \/>\n            Layout.fillWidth: true<br \/>\n            Layout.fillHeight: true<br \/>\n            columns: 2<br \/>\n            columnSpacing: 14<br \/>\n            rowSpacing: 14<\/p>\n<p>            Repeater {<br \/>\n                id: cardRepeater<br \/>\n                model: root.cards<\/p>\n<p>                delegate: Rectangle {<br \/>\n                    id: card<br \/>\n                    property bool playing: true<\/p>\n<p>                    width: (grid.width &#8211; grid.columnSpacing) \/ 2<br \/>\n                    height: (grid.height &#8211; grid.rowSpacing) \/ 2<br \/>\n                    radius: 10<br \/>\n                    color: &#034;#FFFFFF&#034;<br \/>\n                    border.color: card.playing ? &#034;#C9D4E8&#034; : &#034;#E3E6ED&#034;<br \/>\n                    border.width: 1<br \/>\n                    clip: true<\/p>\n<p>                    function setPlaying(on) {<br \/>\n                        playing &#061; on<br \/>\n                        if (on)<br \/>\n                            anim.play()<br \/>\n                        else<br \/>\n                            anim.pause()<br \/>\n                    }<br \/>\n                    \/\/ \u4f9b\u63a7\u4ef6\u5916\u90e8\u7edf\u4e00\u9a71\u52a8\u7684\u51fa\u53e3<br \/>\n                    function childAnim() { return anim }<\/p>\n<p>                    \/\/ \u5b9a\u5c3a\u5bb9\u5668&#xff1a;LottieAnimation \u81ea\u5df1\u7684\u5bbd\u9ad8\u4f1a\u88ab\u7d20\u6750\u5c3a\u5bf8\u8986\u76d6&#xff0c;\u7f29\u653e\u53ea\u80fd\u9760 scale<br \/>\n                    Item {<br \/>\n                        id: animBox<br \/>\n                        readonly property real side: Math.max(50, Math.min(card.width &#8211; 44,<br \/>\n                                                                          card.height &#8211; 30 &#8211; 30))<br \/>\n                        width: side<br \/>\n                        height: side<br \/>\n                        anchors.horizontalCenter: parent.horizontalCenter<br \/>\n                        anchors.top: parent.top<br \/>\n                        anchors.topMargin: 14<\/p>\n<p>                        LottieAnimation {<br \/>\n                            id: anim<br \/>\n                            source: modelData.src<br \/>\n                            autoPlay: true<br \/>\n                            loops: LottieAnimation.Infinite<br \/>\n                            quality: LottieAnimation.MediumQuality<br \/>\n                            transformOrigin: Item.TopLeft<br \/>\n                            scale: (width &gt; 0 &amp;&amp; height &gt; 0)<br \/>\n                                   ? Math.min(animBox.width \/ width, animBox.height \/ height)<br \/>\n                                   : 1<br \/>\n                        }<br \/>\n                    }<\/p>\n<p>                    \/\/ &#8230; \u7701\u7565\u5e95\u90e8\u540d\u79f0\u4e0e\u7d20\u6750\u5c3a\u5bf8\u4fe1\u606f\u6761 &#8230;<\/p>\n<p>                    \/\/ &#8230; \u7701\u7565\u53f3\u4e0a\u89d2\u64ad\u653e\u72b6\u6001\u89d2\u6807 &#8230;<\/p>\n<p>                    \/\/ \u70b9\u5361\u7247\u5355\u72ec\u5f00\u5173\u8fd9\u4e00\u8def\u52a8\u753b<br \/>\n                    MouseArea {<br \/>\n                        anchors.fill: parent<br \/>\n                        anchors.bottomMargin: 30<br \/>\n                        cursorShape: Qt.PointingHandCursor<br \/>\n                        onClicked: {<br \/>\n                            card.setPlaying(!card.playing)<br \/>\n                            root.syncAllPlaying()<br \/>\n                        }<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h4>\u5173\u952e\u903b\u8f91\u8bb2\u89e3<\/h4>\n<h5>\u5c3a\u5bf8\u6539\u4e0d\u52a8\u7684\u6b63\u89e3<\/h5>\n<p>\u56db\u4e2a\u7d20\u6750\u7684\u56fa\u6709\u5c3a\u5bf8\u5404\u4e0d\u76f8\u540c&#xff0c;\u6709 600\u00d7600 \u7684&#xff0c;\u4e5f\u6709 1200\u00d71200 \u7684\u3002\u5982\u679c\u4f60\u76f4\u63a5\u7ed9 LottieAnimation \u5199 width \/ height&#xff0c;\u4f1a\u53d1\u73b0\u5b8c\u5168\u4e0d\u8d77\u4f5c\u7528\u2014\u2014\u56e0\u4e3a\u7d20\u6750\u52a0\u8f7d\u5b8c\u6210\u540e&#xff0c;\u63a7\u4ef6\u5c3a\u5bf8\u4f1a\u88ab\u5f3a\u5236\u6539\u5199\u6210\u7d20\u6750\u672c\u8eab\u7684\u5927\u5c0f\u3002<\/p>\n<p>\u8fd9\u662f Qt \u6e90\u7801\u91cc\u5199\u6b7b\u7684\u884c\u4e3a&#xff0c;\u7d20\u6750 JSON \u91cc\u662f\u591a\u5927&#xff0c;\u63a7\u4ef6\u5c31\u88ab\u6539\u6210\u591a\u5927&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ qt 6.8.2  src\/qtlottie\/src\/imports\/lottieanimation.cpp<\/span><br \/>\n<span class=\"token function\">setWidth<\/span><span class=\"token punctuation\">(<\/span>m_animWidth<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>    <span class=\"token comment\">\/\/ \u7d20\u6750 JSON \u91cc\u7684 &#034;w&#034;<\/span><br \/>\n<span class=\"token function\">setHeight<\/span><span class=\"token punctuation\">(<\/span>m_animHeight<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">\/\/ \u7d20\u6750 JSON \u91cc\u7684 &#034;h&#034;<\/span><\/p>\n<p>\u5b98\u65b9\u6587\u6863\u4e5f\u660e\u786e\u8bf4\u4e86\u8fd9\u4ef6\u4e8b&#xff1a;\u6539 LottieAnimation \u7684\u5bbd\u9ad8\u4e0d\u4f1a\u5f71\u54cd\u52a8\u753b\u663e\u793a\u7684\u5927\u5c0f&#xff0c;\u8981\u63a7\u5236\u5c3a\u5bf8\u5f97\u628a\u5b83\u5957\u5728\u4e00\u4e2a\u5916\u5c42\u5bb9\u5668\u91cc\u3002<\/p>\n<p>\u6240\u4ee5\u6b63\u786e\u505a\u6cd5\u662f&#xff1a;\u5916\u9762\u653e\u4e00\u4e2a Item \u5f53\u300c\u753b\u6846\u300d&#xff0c;\u52a8\u753b\u81ea\u5df1\u7528 scale \u7f29\u8fdb\u53bb\u9002\u914d\u753b\u6846\u3002<\/p>\n<p>Item {<br \/>\n    id: animBox<br \/>\n    width: 230<br \/>\n    height: 230<br \/>\n    anchors.centerIn: parent          \/\/ \u5c45\u4e2d\u7684\u951a\u70b9\u6302\u5728\u3010\u5916\u5c42\u3011<\/p>\n<p>    LottieAnimation {<br \/>\n        id: anim<br \/>\n        source: &#034;qrc:\/lottie\/success.json&#034;<br \/>\n        transformOrigin: Item.TopLeft<br \/>\n        scale: (width &gt; 0 &amp;&amp; height &gt; 0)<br \/>\n               ? Math.min(animBox.width \/ width, animBox.height \/ height)<br \/>\n               : 1                     \/\/ \u52a0\u8f7d\u524d width&#061;0&#xff0c;\u4e0d\u7ed9\u5b88\u536b\u4f1a\u7b97\u51fa NaN<br \/>\n    }<br \/>\n}<\/p>\n<p>\u8fd9\u91cc\u9762\u6709\u4e09\u4e2a\u7ec6\u8282\u90fd\u4e0d\u80fd\u7701&#xff0c;\u5c11\u4e00\u4e2a\u5c31\u4f1a\u51fa\u95ee\u9898\u3002\u7b2c\u4e00\u4e2a\u662f transformOrigin: Item.TopLeft&#xff0c;\u9ed8\u8ba4\u7f29\u653e\u539f\u70b9\u662f\u4e2d\u5fc3&#xff0c;\u7d20\u6750\u7f29\u5c0f\u65f6\u4f1a\u5f80\u4e2d\u95f4\u584c&#xff0c;\u548c\u5de6\u4e0a\u89d2\u5bf9\u9f50\u7684\u5916\u5c42\u5bb9\u5668\u5bf9\u4e0d\u4e0a&#xff0c;\u6240\u4ee5\u5fc5\u987b\u6539\u6210\u4ece\u5de6\u4e0a\u89d2\u5f00\u59cb\u7f29\u3002\u7b2c\u4e8c\u4e2a\u662f\u5c45\u4e2d\u7684 anchors \u5fc5\u987b\u6302\u5728\u5916\u5c42 Item \u4e0a&#xff0c;\u6302\u5728\u5185\u5c42\u7b49\u4e8e\u53bb\u5c45\u4e2d\u90a3\u4e2a 600\u00d7600 \u7684\u5927\u63a7\u4ef6&#xff0c;\u7f29\u5b8c\u7167\u6837\u9519\u4f4d\u3002\u7b2c\u4e09\u4e2a\u662f width &gt; 0 \u7684\u5b88\u536b&#xff0c;\u7d20\u6750\u52a0\u8f7d\u5b8c\u6210\u524d width \u662f 0&#xff0c;\u76f4\u63a5\u505a\u9664\u6cd5\u4f1a\u5f97\u5230 NaN&#xff0c;\u6574\u4e2a\u52a8\u753b\u5c31\u4e0d\u663e\u793a\u4e86\u3002<\/p>\n<p>\u8fd9\u6837\u5199\u8fd8\u6709\u4e2a\u989d\u5916\u597d\u5904&#xff1a;\u6362\u7d20\u6750\u4e0d\u7528\u6539\u6570\u5b57\u3002\u4e0d\u7ba1\u7d20\u6750\u662f 600\u00b2 \u8fd8\u662f 1200\u00b2&#xff0c;Math.min \u90fd\u4f1a\u81ea\u5df1\u7b97\u51fa\u5408\u9002\u7684\u7f29\u653e\u6bd4\u4f8b\u3002\u793a\u4f8b\u91cc\u5361\u7247\u5c3a\u5bf8\u8ddf\u7740\u7a97\u53e3\u53d8&#xff0c;\u52a8\u753b\u4e5f\u4f1a\u81ea\u52a8\u91cd\u65b0\u7f29\u653e&#xff0c;\u539f\u7406\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p>\u987a\u5e26\u63d0\u9192\u4e00\u4e0b&#xff0c;\u4e0d\u8981\u8bd5\u56fe\u53bb\u6539\u7d20\u6750 JSON \u91cc\u7684 w \/ h \u6765\u7f29\u5c0f\u52a8\u753b\u3002Lottie \u7684\u5bbd\u9ad8\u662f\u5408\u6210\u89c6\u53e3&#xff0c;\u56fe\u5c42\u5750\u6807\u662f\u7edd\u5bf9\u5750\u6807&#xff0c;\u6539\u5c0f\u53ea\u4f1a\u88c1\u6389\u5185\u5bb9&#xff0c;\u4e0d\u4f1a\u7b49\u6bd4\u7f29\u5c0f\u3002<\/p>\n<hr \/>\n<h5>\u60f3\u6309\u7f16\u53f7\u53d6\u5361\u7247&#xff0c;\u522b\u627e Grid&#xff0c;\u627e Repeater<\/h5>\n<p>\u7edf\u4e00\u63a7\u5236\u6240\u6709\u5361\u7247\u65f6&#xff0c;\u9700\u8981\u6309\u4e0b\u6807\u4e00\u5f20\u4e00\u5f20\u62ff\u5230\u5b83\u4eec\u3002\u6700\u5f00\u59cb\u6211\u5199\u7684\u662f grid.itemAt(i)&#xff0c;\u8fd0\u884c\u76f4\u63a5\u62a5\u9519\u8bf4 itemAt \u4e0d\u662f\u4e2a\u51fd\u6570\u3002<\/p>\n<p>\u539f\u56e0\u5f88\u7b80\u5355&#xff1a;Grid\u3001Row\u3001Column\u3001Flow \u8fd9\u4e9b\u5e03\u5c40\u7ec4\u4ef6\u53ea\u7ba1\u628a\u5b50\u9879\u6446\u5230\u6b63\u786e\u4f4d\u7f6e&#xff0c;\u5e76\u4e0d\u63d0\u4f9b\u300c\u6309\u4e0b\u6807\u53d6\u5b50\u9879\u300d\u7684\u80fd\u529b\u3002\u8981\u7d22\u5f15\u5b50\u9879&#xff0c;\u5f97\u627e\u5305\u88f9\u5728\u91cc\u9762\u7684 Repeater\u3002<\/p>\n<p>Repeater { id: cardRepeater; model: root.cards; delegate: &#8230; }<\/p>\n<p>\/\/ \u6b63\u786e\u5199\u6cd5<br \/>\ncardRepeater.count<br \/>\ncardRepeater.itemAt(i)<\/p>\n<hr \/>\n<h5>\u6bcf\u5f20\u5361\u7247\u81ea\u5df1\u7ba1\u81ea\u5df1\u7684\u64ad\u653e\u72b6\u6001<\/h5>\n<p>\u6bcf\u5f20\u5361\u7247\u5185\u90e8\u7ef4\u62a4\u81ea\u5df1\u7684\u64ad\u653e\u72b6\u6001&#xff0c;\u5bf9\u5916\u53ea\u66b4\u9732\u4e24\u4e2a\u51fd\u6570&#xff1a;\u4e00\u4e2a\u7528\u6765\u5f00\u5173\u64ad\u653e&#xff0c;\u4e00\u4e2a\u8fd4\u56de\u5185\u90e8\u52a8\u753b\u5bf9\u8c61\u4f9b\u5916\u90e8\u7edf\u4e00\u64cd\u4f5c\u3002<\/p>\n<p>function setPlaying(on) {<br \/>\n    playing &#061; on<br \/>\n    if (on)<br \/>\n        anim.play()<br \/>\n    else<br \/>\n        anim.pause()<br \/>\n}<br \/>\nfunction childAnim() { return anim }<\/p>\n<p>\u9876\u5c42\u4e0d\u76f4\u63a5\u64cd\u4f5c\u52a8\u753b\u63a7\u4ef6&#xff0c;\u800c\u662f\u904d\u5386\u6240\u6709\u5361\u7247\u8c03\u7528 setPlaying()\u3002\u4e4b\u6240\u4ee5\u8981\u7528\u8fd9\u79cd\u300c\u5e7f\u64ad\u4e0b\u53bb\u3001\u5361\u7247\u81ea\u5df1\u6267\u884c\u300d\u7684\u7ed3\u6784&#xff0c;\u662f\u56e0\u4e3a LottieAnimation \u672c\u8eab\u6ca1\u6709 playing \u5c5e\u6027&#xff0c;\u5916\u9762\u8bfb\u4e0d\u5230\u5b83\u5f53\u524d\u5728\u4e0d\u5728\u64ad&#xff0c;\u53ea\u80fd\u5728\u5361\u7247\u91cc\u81ea\u5df1\u7ef4\u62a4\u4e00\u4efd\u72b6\u6001\u3002<\/p>\n<p>\u53cd\u8fc7\u6765&#xff0c;\u70b9\u5355\u5f20\u5361\u7247\u6682\u505c\u540e&#xff0c;\u9876\u90e8\u6309\u94ae\u7684\u6587\u6848\u4e5f\u8981\u8ddf\u7740\u53d8&#xff0c;\u6240\u4ee5\u6709\u4e2a syncAllPlaying() \u53cd\u8fc7\u6765\u67e5\u4e00\u904d\u6240\u6709\u5361\u7247&#xff1a;\u53ea\u8981\u8fd8\u6709\u4e00\u8def\u5728\u64ad&#xff0c;\u6309\u94ae\u5c31\u663e\u793a\u300c\u5168\u90e8\u6682\u505c\u300d&#xff0c;\u5168\u505c\u4e86\u624d\u663e\u793a\u300c\u5168\u90e8\u64ad\u653e\u300d\u3002<\/p>\n<p>\u518d\u8bf4\u8bf4\u300c\u5168\u90e8\u91cd\u64ad\u300d\u4e3a\u4ec0\u4e48\u7528 gotoAndPlay() \u800c\u4e0d\u662f play()\u3002play() \u662f\u4ece\u5f53\u524d\u4f4d\u7f6e\u7ee7\u7eed\u64ad&#xff0c;\u5982\u679c\u52a8\u753b\u5df2\u7ecf\u8dd1\u5230\u4e00\u534a\u4e86&#xff0c;\u70b9\u91cd\u64ad\u4e0d\u4f1a\u6709\u4efb\u4f55\u89c6\u89c9\u53d8\u5316\u3002gotoAndPlay(startFrame) \u624d\u4f1a\u5f3a\u5236\u628a\u64ad\u653e\u5934\u62e8\u56de\u7b2c\u4e00\u5e27\u518d\u5f00\u59cb&#xff0c;\u8fd9\u624d\u662f\u300c\u91cd\u64ad\u300d\u8be5\u6709\u7684\u6548\u679c\u3002\u8fd9\u4e2a\u533a\u522b\u5f88\u5bb9\u6613\u5ffd\u7565&#xff0c;\u8bb0\u4e00\u4e0b\u5c31\u597d\u3002<\/p>\n<hr \/>\n<h5>\u6027\u80fd\u5f00\u9500\u8ddf\u663e\u793a\u5c3a\u5bf8\u6ca1\u5173\u7cfb&#xff0c;\u8ddf\u7d20\u6750\u672c\u8eab\u5927\u5c0f\u6709\u5173<\/h5>\n<p>\u540c\u5c4f\u8dd1\u56db\u8def\u52a8\u753b\u5927\u7ea6 280 \u5e27\/\u79d2&#xff0c;\u8fd8\u7b97\u6d41\u7545\u3002\u4f46\u6210\u672c\u82b1\u5728\u54ea\u5f97\u5fc3\u91cc\u6709\u6570&#xff1a;<\/p>\n<table>\n<tr>\u7d20\u6750\u56fa\u6709\u5c3a\u5bf8\u5361\u7247\u91cc\u663e\u793a<\/tr>\n<tbody>\n<tr>\n<td>\u5bf9\u52fe\u5706\u73af<\/td>\n<td>600\u00d7600<\/td>\n<td>\u7ea6 177 px<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u6863\u626b\u63cf<\/td>\n<td>600\u00d7600<\/td>\n<td>\u7ea6 177 px<\/td>\n<\/tr>\n<tr>\n<td>\u6c99\u6f0f\u52a0\u8f7d<\/td>\n<td>1080\u00d71080<\/td>\n<td>\u7ea6 177 px<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u9664\u6587\u4ef6<\/td>\n<td>1200\u00d71200<\/td>\n<td>\u7ea6 177 px<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>LottieAnimation \u662f\u7528 QPainter \u6e32\u67d3\u7684&#xff0c;\u6bcf\u5e27\u8981\u7ed8\u5236\u7684\u5c3a\u5bf8\u662f\u7d20\u6750\u7684\u56fa\u6709\u5c3a\u5bf8&#xff0c;\u8ddf\u5c4f\u5e55\u4e0a\u663e\u793a\u591a\u5927\u6ca1\u5173\u7cfb\u30021200\u00d71200 \u7684\u7d20\u6750\u7f29\u5230 177 px \u663e\u793a&#xff0c;\u6bcf\u5e27\u7167\u6837\u6309 1200\u00b2 \u7684\u5c3a\u5bf8\u6765\u753b\u3002\u6240\u4ee5\u540c\u5c4f\u8def\u6570\u591a\u3001\u7d20\u6750\u53c8\u5927\u7684\u65f6\u5019&#xff0c;\u6e32\u67d3\u5f00\u9500\u4f1a\u7ebf\u6027\u4e0a\u6da8\u3002<\/p>\n<p>\u793a\u4f8b\u91cc\u7edf\u4e00\u7528\u4e86 MediumQuality \u753b\u8d28\u3002\u4e09\u6863\u753b\u8d28\u7684\u533a\u522b\u5927\u81f4\u662f&#xff1a;LowQuality \u6700\u5feb\u4f46\u753b\u9762\u4e0d\u5e73\u6ed1&#xff0c;HighQuality \u6700\u597d\u770b\u4f46\u5f00\u9500\u6700\u5927&#xff0c;MediumQuality \u4ecb\u4e8e\u4e24\u8005\u4e4b\u95f4\u3002\u56db\u8def\u540c\u8dd1\u65f6\u7528\u4e2d\u6863\u662f\u753b\u9762\u548c\u6027\u80fd\u6bd4\u8f83\u5e73\u8861\u7684\u9009\u62e9\u3002<\/p>\n<h3>\u7cfb\u5217\u6587\u7ae0<\/h3>\n<ul>\n<li>QML \u52a8\u753b\u9009\u62e9&#xff1a;GIF\u4e0eLottie \u7684\u533a\u522b&#xff0c;\u4ee5\u53ca Qt 6.8 \u4e0e 6.11 \u7684 Lottie \u5b9e\u73b0\u5dee\u5f02<\/li>\n<li>QML Lottie\u52a8\u753b&#xff1a;\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d \u3010\u672c\u7bc7\u3011<\/li>\n<li>QML Lottie\u52a8\u753b&#xff1a;\u64ad\u653e\u63a7\u5236\u3001\u9010\u5e27\u62d6\u62fd\u3001\u65b9\u5411\u63a7\u5236<\/li>\n<\/ul>\n<hr \/>\n<p>\u5df2\u9a8c\u8bc1\u73af\u5883&#xff1a;<\/p>\n<ul>\n<li>Qt \u7248\u672c&#xff1a;\u63a8\u8350 Qt 6.11<\/li>\n<li>\u64cd\u4f5c\u7cfb\u7edf&#xff1a;Windows 11<\/li>\n<li>\u5de5\u7a0b\u4e0b\u8f7d&#xff1a;QML \u793a\u4f8b\u5408\u96c6V2.0 &#8211; qml_lottie<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u7528\u4e00\u4e2a\u793a\u4f8b\u628a 4 \u4e2a Lottie \u7d20\u6750\u653e\u5230\u540c\u4e00\u5c4f\u4e0a\u540c\u65f6\u64ad\u653e&#xff0c;\u6f14\u793a\u4e24\u4ef6\u4e8b&#xff1a;\u591a\u8def\u52a8\u753b\u600e\u4e48\u5404\u81ea\u72ec\u7acb\u53c8\u7edf\u4e00\u63a7\u5236&#xff0c;\u4ee5\u53ca LottieAnimation \u90a3\u4e2a\u300c\u5199\u4e86 width \u4e5f\u4e0d\u751f\u6548\u300d\u7684\u5751\u5230\u5e95\u8be5\u600e\u4e48\u89e3\u3002 \u672c\u6587\u662f QML Lottie \u7cfb\u5217\u7b2c 2 \u7bc7&#xff0c;\u5171 3 \u7bc7\u3002 \u52a8\u753b\u5c55\u793a<br \/>\n4 \u4e2a\u7d20\u6750\u5404\u5360\u4e00\u5f20\u5361\u7247&#xff0c;\u8fdb\u5165\u5373\u540c\u65f6\u64ad\u653e\u3002\u9876\u90e8\u4e00\u6392\u662f\u300c\u5168\u90e8\u64ad\u653e \/ \u5168\u90e8\u6682\u505c\u300d\u548c\u300c\u5168\u90e8\u91cd\u64ad\u300d&#xff0c;\u76f4\u63a5\u70b9\u67d0\u5f20\u5361\u7247\u5219\u53ea\u63a7\u5236\u90a3\u4e00\u8def\u3002<\/p>\n","protected":false},"author":2,"featured_media":109922,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6356,5664,218],"topic":[],"class_list":["post-109923","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-6356","tag-qml","tag-qt"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/109923.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u7bc7\u7528\u4e00\u4e2a\u793a\u4f8b\u628a 4 \u4e2a Lottie \u7d20\u6750\u653e\u5230\u540c\u4e00\u5c4f\u4e0a\u540c\u65f6\u64ad\u653e&#xff0c;\u6f14\u793a\u4e24\u4ef6\u4e8b&#xff1a;\u591a\u8def\u52a8\u753b\u600e\u4e48\u5404\u81ea\u72ec\u7acb\u53c8\u7edf\u4e00\u63a7\u5236&#xff0c;\u4ee5\u53ca LottieAnimation \u90a3\u4e2a\u300c\u5199\u4e86 width \u4e5f\u4e0d\u751f\u6548\u300d\u7684\u5751\u5230\u5e95\u8be5\u600e\u4e48\u89e3\u3002 \u672c\u6587\u662f QML Lottie \u7cfb\u5217\u7b2c 2 \u7bc7&#xff0c;\u5171 3 \u7bc7\u3002 \u52a8\u753b\u5c55\u793a 4 \u4e2a\u7d20\u6750\u5404\u5360\u4e00\u5f20\u5361\u7247&#xff0c;\u8fdb\u5165\u5373\u540c\u65f6\u64ad\u653e\u3002\u9876\u90e8\u4e00\u6392\u662f\u300c\u5168\u90e8\u64ad\u653e \/ \u5168\u90e8\u6682\u505c\u300d\u548c\u300c\u5168\u90e8\u91cd\u64ad\u300d&#xff0c;\u76f4\u63a5\u70b9\u67d0\u5f20\u5361\u7247\u5219\u53ea\u63a7\u5236\u90a3\u4e00\u8def\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/109923.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-25T00:32:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260925003256-6ab5c138d4f72.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/109923.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/109923.html\",\"name\":\"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-25T00:32:58+00:00\",\"dateModified\":\"2026-09-25T00:32:58+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/109923.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/109923.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/109923.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/109923.html","og_locale":"zh_CN","og_type":"article","og_title":"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u8fd9\u7bc7\u7528\u4e00\u4e2a\u793a\u4f8b\u628a 4 \u4e2a Lottie \u7d20\u6750\u653e\u5230\u540c\u4e00\u5c4f\u4e0a\u540c\u65f6\u64ad\u653e&#xff0c;\u6f14\u793a\u4e24\u4ef6\u4e8b&#xff1a;\u591a\u8def\u52a8\u753b\u600e\u4e48\u5404\u81ea\u72ec\u7acb\u53c8\u7edf\u4e00\u63a7\u5236&#xff0c;\u4ee5\u53ca LottieAnimation \u90a3\u4e2a\u300c\u5199\u4e86 width \u4e5f\u4e0d\u751f\u6548\u300d\u7684\u5751\u5230\u5e95\u8be5\u600e\u4e48\u89e3\u3002 \u672c\u6587\u662f QML Lottie \u7cfb\u5217\u7b2c 2 \u7bc7&#xff0c;\u5171 3 \u7bc7\u3002 \u52a8\u753b\u5c55\u793a 4 \u4e2a\u7d20\u6750\u5404\u5360\u4e00\u5f20\u5361\u7247&#xff0c;\u8fdb\u5165\u5373\u540c\u65f6\u64ad\u653e\u3002\u9876\u90e8\u4e00\u6392\u662f\u300c\u5168\u90e8\u64ad\u653e \/ \u5168\u90e8\u6682\u505c\u300d\u548c\u300c\u5168\u90e8\u91cd\u64ad\u300d&#xff0c;\u76f4\u63a5\u70b9\u67d0\u5f20\u5361\u7247\u5219\u53ea\u63a7\u5236\u90a3\u4e00\u8def\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/109923.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-25T00:32:58+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260925003256-6ab5c138d4f72.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/109923.html","url":"https:\/\/www.wsisp.com\/helps\/109923.html","name":"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-25T00:32:58+00:00","dateModified":"2026-09-25T00:32:58+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/109923.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/109923.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/109923.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"QML Lottie\u52a8\u753b\uff1a\u7d20\u6750\u72ec\u7acb\u63a7\u5236\u4e0e\u5c3a\u5bf8\u9002\u914d"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/109923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=109923"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/109923\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/109922"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=109923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=109923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=109923"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=109923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}