{"id":120483,"date":"2026-10-31T19:48:28","date_gmt":"2026-10-31T11:48:28","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/120483.html"},"modified":"2026-10-31T19:48:28","modified_gmt":"2026-10-31T11:48:28","slug":"qml%e8%bf%9b%e9%98%b6%e5%ae%9e%e6%88%98%e4%ba%8c%ef%bc%9a%e5%bc%82%e6%ad%a5%e7%bd%91%e7%bb%9c%e3%80%81%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96%e4%b8%8e%e5%b7%a5%e7%a8%8b%e5%8c%96%e8%90%bd%e5%9c%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/120483.html","title":{"rendered":"QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730"},"content":{"rendered":"<h3>1. \u5f15\u8a00<\/h3>\n<p>\u5728 QML \u8fdb\u9636&#xff08;\u4e00&#xff09;\u4e2d&#xff0c;\u6211\u4eec\u5df2\u7ecf\u638c\u63e1\u4e86\u5c5e\u6027\u7ed1\u5b9a\u3001\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u3001\u72b6\u6001\u4e0e\u52a8\u753b\u3001\u6a21\u578b\u89c6\u56fe\u7b49\u57fa\u7840\u80fd\u529b\u3002\u6b64\u65f6\u4f60\u5927\u6982\u7387\u5df2\u7ecf\u80fd\u5199\u51fa\u4e00\u4e2a\u201c\u80fd\u8dd1\u8d77\u6765\u201d\u7684\u754c\u9762&#xff0c;\u4f46\u771f\u6b63\u8fdb\u5165\u9879\u76ee\u5f00\u53d1\u540e&#xff0c;\u95ee\u9898\u4f1a\u96c6\u4e2d\u51fa\u73b0\u5728\u4e09\u4e2a\u65b9\u5411&#xff1a;<\/p>\n<ul>\n<li>\u5f02\u6b65\u4e0e\u7f51\u7edc&#xff1a;\u754c\u9762\u5361\u987f\u3001\u8bf7\u6c42\u963b\u585e UI \u7ebf\u7a0b\u3001\u8de8\u7ebf\u7a0b\u6570\u636e\u4f20\u9012\u51fa\u9519\u3002<\/li>\n<li>\u6027\u80fd\u4f18\u5316&#xff1a;\u7ed1\u5b9a\u5c42\u7ea7\u8fc7\u6df1\u3001\u5217\u8868\u6eda\u52a8\u6389\u5e27\u3001delegate \u91cc\u505a\u91cd\u8ba1\u7b97\u3002<\/li>\n<li>\u5de5\u7a0b\u5316&#xff1a;\u4ee3\u7801\u8d8a\u5199\u8d8a\u4e71\u3001\u6a21\u5757\u8fb9\u754c\u4e0d\u6e05\u3001\u8d44\u6e90\u52a0\u8f7d\u6162\u3001\u591a\u8bed\u8a00\u9002\u914d\u56f0\u96be\u3002<\/li>\n<\/ul>\n<p>\u672c\u6587\u5c31\u56f4\u7ed5\u8fd9\u4e09\u6761\u4e3b\u7ebf\u5c55\u5f00&#xff0c;\u5c3d\u91cf\u628a\u201c\u4e3a\u4ec0\u4e48\u201d\u8bb2\u6e05\u695a&#xff0c;\u518d\u7ed9\u51fa\u201c\u600e\u4e48\u505a\u201d\u7684\u4ee3\u7801\u793a\u4f8b&#xff0c;\u5e2e\u52a9\u4f60\u4e3a\u540e\u7eed\u7684\u4e2d\u5927\u578b QML \u9879\u76ee\u6253\u4e0b\u57fa\u7840\u3002<\/p>\n<h3>2. \u5f02\u6b65\u4e0e\u7f51\u7edc<\/h3>\n<h4>2.1 \u4e3a\u4ec0\u4e48\u9700\u8981\u5f02\u6b65<\/h4>\n<p>QML \u7684\u754c\u9762\u6e32\u67d3\u548c JavaScript \u903b\u8f91\u9ed8\u8ba4\u90fd\u8fd0\u884c\u5728\u4e3b\u7ebf\u7a0b&#xff08;GUI \u7ebf\u7a0b&#xff09;\u4e0a\u3002\u4efb\u4f55\u8017\u65f6\u64cd\u4f5c\u2014\u2014\u5927\u6587\u4ef6\u8bfb\u53d6\u3001\u590d\u6742\u8ba1\u7b97\u3001\u7f51\u7edc\u8bf7\u6c42\u7684\u540c\u6b65\u7b49\u5f85\u2014\u2014\u90fd\u4f1a\u76f4\u63a5\u963b\u585e\u4e3b\u7ebf\u7a0b&#xff0c;\u8868\u73b0\u4e3a\u754c\u9762\u5361\u6b7b\u3001\u52a8\u753b\u505c\u987f\u3001\u70b9\u51fb\u65e0\u54cd\u5e94\u3002<\/p>\n<p>\u56e0\u6b64 QML \u4e2d\u7684\u5f02\u6b65\u624b\u6bb5\u4e3b\u8981\u89e3\u51b3\u4e24\u7c7b\u95ee\u9898&#xff1a;<\/p>\n<li>\u628a\u8017\u65f6\u903b\u8f91\u632a\u51fa\u4e3b\u7ebf\u7a0b&#xff1a;\u4f8b\u5982 WorkerScript\u3001C&#043;&#043; \u7684 QThread \/ QtConcurrent\u3002<\/li>\n<li>\u628a\u7f51\u7edc IO \u53d8\u6210\u975e\u963b\u585e\u56de\u8c03&#xff1a;\u4f8b\u5982 XMLHttpRequest\u3001QNetworkAccessManager \u7684\u4fe1\u53f7\u69fd\u673a\u5236\u3002<\/li>\n<h4>2.2 WorkerScript<\/h4>\n<p>QML \u91cc\u7684\u201c\u8f7b\u91cf\u7ea7\u7ebf\u7a0b\u201d&#xff0c;WorkerScript \u5141\u8bb8\u4f60\u5728\u4e00\u4e2a\u72ec\u7acb\u7684 JavaScript \u7ebf\u7a0b\u4e2d\u6267\u884c\u811a\u672c&#xff0c;\u4e3b\u7ebf\u7a0b\u901a\u8fc7\u6d88\u606f\u4e0e\u5b83\u901a\u4fe1\u3002\u5b83\u9002\u5408\u5904\u7406\u7eaf JS \u7684\u8017\u65f6\u8ba1\u7b97&#xff0c;\u6bd4\u5982\u6570\u636e\u89e3\u6790\u3001\u6279\u91cf\u683c\u5f0f\u5316\u3001\u52a0\u5bc6\u54c8\u5e0c\u7b49\u3002<\/p>\n<p>\u57fa\u672c\u7528\u6cd5&#xff1a;\u5148\u51c6\u5907\u4e00\u4e2a worker \u811a\u672c\u6587\u4ef6 work.js&#xff1a;<\/p>\n<p>\/\/ work.js<br \/>\nWorkerScript.onMessage &#061; function (message) {<br \/>\n    \/\/ \u6a21\u62df\u8017\u65f6\u8ba1\u7b97<br \/>\n    var total &#061; 0;<br \/>\n    for (var i &#061; 0; i &lt; message.count; i&#043;&#043;) {<br \/>\n        total &#043;&#061; Math.sqrt(i);<br \/>\n    }<br \/>\n    \/\/ \u628a\u7ed3\u679c\u56de\u4f20\u7ed9\u4e3b\u7ebf\u7a0b<br \/>\n    WorkerScript.sendMessage({ result: total });<br \/>\n};<\/p>\n<p>\u4e3b\u7ebf\u7a0b\u4fa7\u8fd9\u6837\u4f7f\u7528&#xff1a;<\/p>\n<p>import QtQuick 2.15<\/p>\n<p>Item {<br \/>\n    WorkerScript {<br \/>\n        id: worker<br \/>\n        source: &#034;work.js&#034;<br \/>\n        onMessage: function (messageObject) {<br \/>\n            console.log(&#034;\u8ba1\u7b97\u7ed3\u679c&#xff1a;&#034;, messageObject.result)<br \/>\n        }<br \/>\n    }<\/p>\n<p>    Component.onCompleted: {<br \/>\n        worker.sendMessage({ count: 1000000 })<br \/>\n    }<br \/>\n}<\/p>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>WorkerScript \u4e2d\u4e0d\u80fd\u8bbf\u95ee QML \u5bf9\u8c61&#xff0c;\u53ea\u80fd\u901a\u8fc7 sendMessage \/ onMessage \u4f20\u9012\u53ef\u5e8f\u5217\u5316\u7684\u6570\u636e\u3002<\/li>\n<li>\u4f20\u9012\u7684\u6570\u636e\u4f1a\u88ab\u590d\u5236&#xff0c;\u4e0d\u662f\u5171\u4eab\u5f15\u7528&#xff0c;\u56e0\u6b64\u4e0d\u8981\u6307\u671b\u5728 worker \u91cc\u4fee\u6539\u4e3b\u7ebf\u7a0b\u7684\u5bf9\u8c61\u3002<\/li>\n<li>WorkerScript \u662f\u5355\u7ebf\u7a0b\u7684&#xff0c;\u4e00\u4e2a WorkerScript \u5b9e\u4f8b\u5bf9\u5e94\u4e00\u4e2a worker \u7ebf\u7a0b&#xff0c;\u591a\u4e2a\u4efb\u52a1\u4f1a\u6392\u961f\u6267\u884c\u3002<\/li>\n<li>\u5b83\u9002\u5408\u201c\u8ba1\u7b97\u5bc6\u96c6\u4f46\u6570\u636e\u91cf\u4e0d\u5927\u201d\u7684\u573a\u666f&#xff1b;\u5982\u679c\u6d89\u53ca\u5927\u91cf\u4e8c\u8fdb\u5236\u6570\u636e\u6216\u590d\u6742\u4e1a\u52a1&#xff0c;\u5efa\u8bae\u4e0b\u6c89\u5230 C&#043;&#043;\u3002<\/li>\n<\/ul>\n<h4>2.3 XMLHttpRequest<\/h4>\n<p>QML \u7684 JavaScript \u73af\u5883\u5185\u7f6e\u4e86 XMLHttpRequest&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u53d1\u8d77\u5f02\u6b65 HTTP \u8bf7\u6c42&#xff0c;\u9002\u5408\u8f7b\u91cf\u7ea7\u63a5\u53e3\u8c03\u7528\u3002<\/p>\n<p>import QtQuick 2.15<\/p>\n<p>Item {<br \/>\n    function fetchUser(id) {<br \/>\n        var xhr &#061; new XMLHttpRequest()<br \/>\n        xhr.open(&#034;GET&#034;, &#034;https:\/\/api.example.com\/users\/&#034; &#043; id, true)<br \/>\n        xhr.onreadystatechange &#061; function () {<br \/>\n            if (xhr.readyState &#061;&#061;&#061; XMLHttpRequest.DONE) {<br \/>\n                if (xhr.status &#061;&#061;&#061; 200) {<br \/>\n                    var data &#061; JSON.parse(xhr.responseText)<br \/>\n                    console.log(&#034;\u7528\u6237\u540d&#xff1a;&#034;, data.name)<br \/>\n                } else {<br \/>\n                    console.warn(&#034;\u8bf7\u6c42\u5931\u8d25&#xff0c;\u72b6\u6001\u7801&#xff1a;&#034;, xhr.status)<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n        xhr.setRequestHeader(&#034;Accept&#034;, &#034;application\/json&#034;)<br \/>\n        xhr.send()<br \/>\n    }<\/p>\n<p>    Component.onCompleted: fetchUser(1)<br \/>\n}<\/p>\n<p>\u4f7f\u7528\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u7b2c\u4e09\u4e2a\u53c2\u6570 true \u8868\u793a\u5f02\u6b65&#xff0c;\u52a1\u5fc5\u4f7f\u7528\u5f02\u6b65&#xff0c;\u540c\u6b65\u8bf7\u6c42\u4f1a\u963b\u585e UI\u3002<\/li>\n<li>\u6ce8\u610f\u5904\u7406\u8d85\u65f6\u3001\u9519\u8bef\u72b6\u6001\u7801\u548c JSON \u89e3\u6790\u5f02\u5e38&#xff0c;\u907f\u514d\u4e00\u4e2a\u63a5\u53e3\u5931\u8d25\u5bfc\u81f4\u6574\u4e2a\u9875\u9762\u903b\u8f91\u4e2d\u65ad\u3002<\/li>\n<li>XMLHttpRequest \u7684\u80fd\u529b\u6709\u9650&#xff08;\u4e0d\u652f\u6301\u8fde\u63a5\u590d\u7528\u3001\u62e6\u622a\u5668\u3001\u4e0a\u4f20\u8fdb\u5ea6\u7b49\u9ad8\u7ea7\u7279\u6027&#xff09;&#xff0c;\u590d\u6742\u9879\u76ee\u5efa\u8bae\u4f7f\u7528 C&#043;&#043; \u5c01\u88c5\u3002<\/li>\n<\/ul>\n<h4>2.4 QNetworkAccessManager<\/h4>\n<p>\u5f53\u9879\u76ee\u9700\u8981\u7edf\u4e00\u7ba1\u7406\u8bf7\u6c42\u5934\u3001\u9274\u6743\u3001\u91cd\u8bd5\u3001\u8d85\u65f6\u3001\u5e76\u53d1\u63a7\u5236\u65f6&#xff0c;\u63a8\u8350\u5728 C&#043;&#043; \u4fa7\u4f7f\u7528 QNetworkAccessManager \u5c01\u88c5\u7f51\u7edc\u5c42&#xff0c;\u518d\u901a\u8fc7 Q_INVOKABLE \u65b9\u6cd5\u6216\u4fe1\u53f7\u66b4\u9732\u7ed9 QML\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u5b9a\u4e49\u7f51\u7edc\u7ba1\u7406\u7c7b<\/p>\n<p>\/\/ NetworkManager.h<br \/>\n#ifndef NETWORKMANAGER_H<br \/>\n#define NETWORKMANAGER_H<\/p>\n<p>#include &lt;QObject&gt;<br \/>\n#include &lt;QNetworkAccessManager&gt;<br \/>\n#include &lt;QNetworkReply&gt;<\/p>\n<p>class NetworkManager : public QObject<br \/>\n{<br \/>\n    Q_OBJECT<br \/>\npublic:<br \/>\n    explicit NetworkManager(QObject *parent &#061; nullptr);<\/p>\n<p>    Q_INVOKABLE void get(const QString &amp;url);<\/p>\n<p>signals:<br \/>\n    void requestFinished(const QString &amp;url, const QString &amp;body);<br \/>\n    void requestFailed(const QString &amp;url, const QString &amp;error);<\/p>\n<p>private:<br \/>\n    QNetworkAccessManager m_manager;<br \/>\n};<\/p>\n<p>#endif \/\/ NETWORKMANAGER_H<\/p>\n<p>\/\/ NetworkManager.cpp<br \/>\n#include &#034;NetworkManager.h&#034;<\/p>\n<p>NetworkManager::NetworkManager(QObject *parent)<br \/>\n    : QObject(parent)<br \/>\n{<br \/>\n}<\/p>\n<p>void NetworkManager::get(const QString &amp;url)<br \/>\n{<br \/>\n    QNetworkRequest request{QUrl(url)};<br \/>\n    request.setHeader(QNetworkRequest::ContentTypeHeader, &#034;application\/json&#034;);<\/p>\n<p>    QNetworkReply *reply &#061; m_manager.get(request);<\/p>\n<p>    connect(reply, &amp;QNetworkReply::finished, this, [this, reply, url]() {<br \/>\n        if (reply-&gt;error() &#061;&#061; QNetworkReply::NoError) {<br \/>\n            emit requestFinished(url, QString::fromUtf8(reply-&gt;readAll()));<br \/>\n        } else {<br \/>\n            emit requestFailed(url, reply-&gt;errorString());<br \/>\n        }<br \/>\n        reply-&gt;deleteLater();<br \/>\n    });<br \/>\n}<\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u6ce8\u518c\u5230 QML \u4e0a\u4e0b\u6587<\/p>\n<p>\/\/ main.cpp<br \/>\n#include &lt;QGuiApplication&gt;<br \/>\n#include &lt;QQmlApplicationEngine&gt;<br \/>\n#include &lt;QQmlContext&gt;<br \/>\n#include &#034;NetworkManager.h&#034;<\/p>\n<p>int main(int argc, char *argv[])<br \/>\n{<br \/>\n    QGuiApplication app(argc, argv);<\/p>\n<p>    NetworkManager network;<br \/>\n    QQmlApplicationEngine engine;<br \/>\n    engine.rootContext()-&gt;setContextProperty(&#034;network&#034;, &amp;network);<br \/>\n    engine.load(QUrl(QStringLiteral(&#034;qrc:\/main.qml&#034;)));<\/p>\n<p>    return app.exec();<br \/>\n}<\/p>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u5728 QML \u4e2d\u8c03\u7528<\/p>\n<p>import QtQuick 2.15<\/p>\n<p>Item {<br \/>\n    Connections {<br \/>\n        target: network<br \/>\n        function onRequestFinished(url, body) {<br \/>\n            console.log(&#034;\u54cd\u5e94&#xff1a;&#034;, url, body)<br \/>\n        }<br \/>\n        function onRequestFailed(url, error) {<br \/>\n            console.warn(&#034;\u5931\u8d25&#xff1a;&#034;, url, error)<br \/>\n        }<br \/>\n    }<\/p>\n<p>    Component.onCompleted: network.get(&#034;https:\/\/api.example.com\/users\/1&#034;)<br \/>\n}<\/p>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u8d85\u65f6\u4e0e\u91cd\u8bd5<\/p>\n<p>\u771f\u5b9e\u7f51\u7edc\u73af\u5883\u91cc&#xff0c;\u8bf7\u6c42\u53ef\u80fd\u56e0\u4e3a\u5f31\u7f51\u3001\u670d\u52a1\u7aef\u6296\u52a8\u800c\u957f\u65f6\u95f4\u6302\u8d77\u3002\u751f\u4ea7\u7ea7\u7f51\u7edc\u5c42\u5fc5\u987b\u7ed9\u6bcf\u4e2a\u8bf7\u6c42\u8bbe\u7f6e\u8d85\u65f6&#xff0c;\u5e76\u5728\u5931\u8d25\u540e\u6309\u7b56\u7565\u91cd\u8bd5\u3002\u4e0b\u9762\u5728 NetworkManager \u4e2d\u5f15\u5165 QTimer \u5b9e\u73b0 5 \u79d2\u8d85\u65f6&#xff0c;\u5931\u8d25\u540e\u6700\u591a\u91cd\u8bd5 2 \u6b21\u3002<\/p>\n<p>\u5148\u6269\u5c55\u5934\u6587\u4ef6&#xff0c;\u589e\u52a0\u91cd\u8bd5\u6b21\u6570\u53c2\u6570\u4e0e\u5185\u90e8\u8bf7\u6c42\u65b9\u6cd5&#xff1a;<\/p>\n<p>\/\/ NetworkManager.h<br \/>\n#ifndef NETWORKMANAGER_H<br \/>\n#define NETWORKMANAGER_H<\/p>\n<p>#include &lt;QObject&gt;<br \/>\n#include &lt;QNetworkAccessManager&gt;<br \/>\n#include &lt;QNetworkReply&gt;<br \/>\n#include &lt;QTimer&gt;<\/p>\n<p>class NetworkManager : public QObject<br \/>\n{<br \/>\n    Q_OBJECT<br \/>\npublic:<br \/>\n    explicit NetworkManager(QObject *parent &#061; nullptr);<\/p>\n<p>    \/\/ retries \u8868\u793a\u201c\u5931\u8d25\u540e\u8fd8\u80fd\u518d\u8bd5\u51e0\u6b21\u201d&#xff0c;\u9ed8\u8ba4 2 \u6b21<br \/>\n    Q_INVOKABLE void get(const QString &amp;url, int retries &#061; 2);<\/p>\n<p>signals:<br \/>\n    void requestFinished(const QString &amp;url, const QString &amp;body);<br \/>\n    void requestFailed(const QString &amp;url, const QString &amp;error);<\/p>\n<p>private:<br \/>\n    void doGet(const QString &amp;url, int retriesLeft);<\/p>\n<p>    QNetworkAccessManager m_manager;<br \/>\n    static constexpr int kTimeoutMs &#061; 5000;   \/\/ 5 \u79d2\u8d85\u65f6<br \/>\n};<\/p>\n<p>#endif \/\/ NETWORKMANAGER_H<\/p>\n<p>\u5b9e\u73b0\u90e8\u5206&#xff1a;\u6bcf\u6b21\u8bf7\u6c42\u90fd\u6302\u4e00\u4e2a QTimer&#xff0c;\u8d85\u65f6\u540e\u8c03\u7528 reply-&gt;abort()&#xff1b;\u5728 finished \u56de\u8c03\u91cc\u7edf\u4e00\u5224\u65ad\u662f\u5426\u9700\u8981\u91cd\u8bd5\u3002<\/p>\n<p>\/\/ NetworkManager.cpp<br \/>\n#include &#034;NetworkManager.h&#034;<\/p>\n<p>NetworkManager::NetworkManager(QObject *parent)<br \/>\n    : QObject(parent)<br \/>\n{<br \/>\n}<\/p>\n<p>void NetworkManager::get(const QString &amp;url, int retries)<br \/>\n{<br \/>\n    doGet(url, retries);<br \/>\n}<\/p>\n<p>void NetworkManager::doGet(const QString &amp;url, int retriesLeft)<br \/>\n{<br \/>\n    QNetworkRequest request{QUrl(url)};<br \/>\n    request.setHeader(QNetworkRequest::ContentTypeHeader, &#034;application\/json&#034;);<\/p>\n<p>    QNetworkReply *reply &#061; m_manager.get(request);<\/p>\n<p>    \/\/ 1. \u4e3a\u672c\u6b21\u8bf7\u6c42\u521b\u5efa\u8d85\u65f6\u5b9a\u65f6\u5668<br \/>\n    QTimer *timer &#061; new QTimer(reply);<br \/>\n    timer-&gt;setSingleShot(true);<br \/>\n    timer-&gt;setInterval(kTimeoutMs);<\/p>\n<p>    connect(timer, &amp;QTimer::timeout, reply, [reply]() {<br \/>\n        \/\/ \u8d85\u65f6\u540e\u4e3b\u52a8\u4e2d\u65ad&#xff0c;\u4f1a\u89e6\u53d1 finished \u4fe1\u53f7&#xff0c;error \u4e3a OperationCanceledError<br \/>\n        reply-&gt;abort();<br \/>\n    });<br \/>\n    timer-&gt;start();<\/p>\n<p>    \/\/ 2. \u8bf7\u6c42\u7ed3\u675f&#xff08;\u6210\u529f\u3001\u5931\u8d25\u6216\u8d85\u65f6&#xff09;\u7edf\u4e00\u5904\u7406<br \/>\n    connect(reply, &amp;QNetworkReply::finished, this, [this, reply, url, retriesLeft]() {<br \/>\n        reply-&gt;deleteLater();<\/p>\n<p>        if (reply-&gt;error() &#061;&#061; QNetworkReply::NoError) {<br \/>\n            emit requestFinished(url, QString::fromUtf8(reply-&gt;readAll()));<br \/>\n            return;<br \/>\n        }<\/p>\n<p>        \/\/ 3. \u5931\u8d25\u540e\u5224\u65ad\u662f\u5426\u8fd8\u80fd\u91cd\u8bd5<br \/>\n        if (retriesLeft &gt; 0) {<br \/>\n            qWarning() &lt;&lt; &#034;\u8bf7\u6c42\u5931\u8d25&#xff0c;\u51c6\u5907\u91cd\u8bd5&#xff1a;&#034; &lt;&lt; url<br \/>\n                     &lt;&lt; &#034;\u5269\u4f59\u91cd\u8bd5\u6b21\u6570&#xff1a;&#034; &lt;&lt; retriesLeft<br \/>\n                     &lt;&lt; &#034;\u539f\u56e0&#xff1a;&#034; &lt;&lt; reply-&gt;errorString();<br \/>\n            doGet(url, retriesLeft &#8211; 1);<br \/>\n        } else {<br \/>\n            emit requestFailed(url, reply-&gt;errorString());<br \/>\n        }<br \/>\n    });<br \/>\n}<\/p>\n<p>\u5b9e\u73b0\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>QTimer \u4ee5 reply \u4e3a\u7236\u5bf9\u8c61&#xff0c;reply \u9500\u6bc1\u65f6\u5b9a\u65f6\u5668\u81ea\u52a8\u91ca\u653e&#xff0c;\u4e0d\u4f1a\u6cc4\u6f0f\u3002<\/li>\n<li>reply-&gt;abort() \u4f1a\u8ba9 finished \u4fe1\u53f7\u7167\u5e38\u53d1\u51fa&#xff0c;\u9519\u8bef\u7c7b\u578b\u4e3a QNetworkReply::OperationCanceledError&#xff0c;\u56e0\u6b64\u8d85\u65f6\u548c\u666e\u901a\u5931\u8d25\u53ef\u4ee5\u8d70\u540c\u4e00\u5957\u91cd\u8bd5\u903b\u8f91\u3002<\/li>\n<li>\u91cd\u8bd5\u6b21\u6570\u901a\u8fc7\u53c2\u6570\u9012\u51cf\u4f20\u9012&#xff0c;\u907f\u514d\u4f7f\u7528\u6210\u5458\u53d8\u91cf\u5bfc\u81f4\u5e76\u53d1\u8bf7\u6c42\u4e92\u76f8\u5e72\u6270\u3002<\/li>\n<li>\u5982\u679c\u4e1a\u52a1\u4e0a\u9700\u8981\u533a\u5206\u201c\u8d85\u65f6\u201d\u548c\u201c\u670d\u52a1\u7aef\u9519\u8bef\u201d&#xff0c;\u53ef\u4ee5\u5728 abort() \u524d\u7ed9 reply \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u5c5e\u6027&#xff08;\u5982 reply-&gt;setProperty(&#034;timeout&#034;, true)&#xff09;&#xff0c;\u5728\u56de\u8c03\u91cc\u8bfb\u53d6\u3002<\/li>\n<li>\u91cd\u8bd5\u5efa\u8bae\u914d\u5408\u9000\u907f\u7b56\u7565&#xff08;\u5982 1s\u30012s \u9012\u589e&#xff09;&#xff0c;\u907f\u514d\u77ac\u65f6\u91cd\u8bd5\u628a\u670d\u52a1\u7aef\u6253\u57ae\u3002<\/li>\n<\/ul>\n<p>QML \u4fa7\u7edf\u4e00\u63d0\u793a\u7528\u6237&#xff1a;\u91cd\u8bd5\u5168\u90e8\u5931\u8d25\u540e&#xff0c;C&#043;&#043; \u4fa7\u53ea\u4f1a\u53d1\u51fa\u4e00\u6b21 requestFailed&#xff0c;QML \u53ea\u9700\u5728 Connections \u4e2d\u96c6\u4e2d\u5904\u7406&#xff0c;\u5c31\u80fd\u4fdd\u8bc1\u7528\u6237\u4e0d\u4f1a\u770b\u5230\u91cd\u590d\u7684\u9519\u8bef\u5f39\u7a97\u3002<\/p>\n<p>import QtQuick 2.15<br \/>\nimport QtQuick.Controls 2.15<\/p>\n<p>Item {<br \/>\n    id: root<\/p>\n<p>    \/\/ \u7edf\u4e00\u7684\u9519\u8bef\u63d0\u793a\u6761<br \/>\n    Rectangle {<br \/>\n        id: errorBar<br \/>\n        anchors.top: parent.top<br \/>\n        anchors.left: parent.left<br \/>\n        anchors.right: parent.right<br \/>\n        height: 40<br \/>\n        color: &#034;#fdecea&#034;<br \/>\n        visible: false<\/p>\n<p>        Text {<br \/>\n            id: errorText<br \/>\n            anchors.centerIn: parent<br \/>\n            color: &#034;#c0392b&#034;<br \/>\n            font.pixelSize: 14<br \/>\n        }<\/p>\n<p>        Timer {<br \/>\n            id: hideTimer<br \/>\n            interval: 3000<br \/>\n            onTriggered: errorBar.visible &#061; false<br \/>\n        }<br \/>\n    }<\/p>\n<p>    Connections {<br \/>\n        target: network<\/p>\n<p>        function onRequestFinished(url, body) {<br \/>\n            console.log(&#034;\u54cd\u5e94&#xff1a;&#034;, url, body)<br \/>\n        }<\/p>\n<p>        function onRequestFailed(url, error) {<br \/>\n            \/\/ \u91cd\u8bd5\u5df2\u8017\u5c3d&#xff0c;\u8fd9\u91cc\u53ea\u63d0\u793a\u4e00\u6b21<br \/>\n            errorText.text &#061; qsTr(&#034;\u7f51\u7edc\u8bf7\u6c42\u5931\u8d25&#xff1a;%1&#034;).arg(error)<br \/>\n            errorBar.visible &#061; true<br \/>\n            hideTimer.restart()<br \/>\n        }<br \/>\n    }<\/p>\n<p>    Component.onCompleted: network.get(&#034;https:\/\/api.example.com\/users\/1&#034;)<br \/>\n}<\/p>\n<p>\u8fd9\u6837\u5206\u5c42\u7684\u597d\u5904\u662f&#xff1a;\u91cd\u8bd5\u4e0e\u8d85\u65f6\u5c5e\u4e8e\u7f51\u7edc\u5c42\u804c\u8d23&#xff0c;QML \u4e0d\u9700\u8981\u5173\u5fc3\u5185\u90e8\u91cd\u8bd5\u4e86\u51e0\u6b21&#xff0c;\u53ea\u8d1f\u8d23\u628a\u6700\u7ec8\u5931\u8d25\u7ed3\u679c\u4ee5\u7edf\u4e00\u65b9\u5f0f\u5448\u73b0\u7ed9\u7528\u6237&#xff0c;\u754c\u9762\u903b\u8f91\u4fdd\u6301\u5e72\u51c0\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u63a8\u8350 C&#043;&#043; \u7f51\u7edc\u5c42&#xff1a;<\/p>\n<ul>\n<li>QNetworkAccessManager \u5929\u7136\u5f02\u6b65&#xff0c;\u57fa\u4e8e\u4e8b\u4ef6\u5faa\u73af&#xff0c;\u4e0d\u4f1a\u963b\u585e UI\u3002<\/li>\n<li>\u53ef\u4ee5\u7edf\u4e00\u5904\u7406\u8d85\u65f6&#xff08;QTimer &#043; reply-&gt;abort()&#xff09;\u3001\u91cd\u8bd5\u3001\u9274\u6743 Token \u6ce8\u5165\u3002<\/li>\n<li>\u652f\u6301\u8fde\u63a5\u590d\u7528\u3001\u4ee3\u7406\u3001SSL \u914d\u7f6e&#xff0c;\u4fbf\u4e8e\u505a\u4f01\u4e1a\u7ea7\u7f51\u7edc\u89c4\u8303\u3002<\/li>\n<li>\u4e1a\u52a1\u903b\u8f91\u4e0e\u754c\u9762\u89e3\u8026&#xff0c;QML \u53ea\u8d1f\u8d23\u5c55\u793a&#xff0c;\u4fbf\u4e8e\u6d4b\u8bd5\u548c\u7ef4\u62a4\u3002<\/li>\n<\/ul>\n<h4>2.5 \u4e09\u79cd\u5f02\u6b65\u65b9\u6848\u5bf9\u6bd4<\/h4>\n<p>WorkerScript\u3001XMLHttpRequest \u548c C&#043;&#043; \u4fa7\u7684 QNetworkAccessManager \u89e3\u51b3\u7684\u662f\u4e0d\u540c\u5c42\u9762\u7684\u95ee\u9898&#xff0c;\u4e0b\u9762\u4ece\u4e94\u4e2a\u7ef4\u5ea6\u505a\u4e00\u6b21\u6a2a\u5411\u5bf9\u6bd4&#xff0c;\u65b9\u4fbf\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5feb\u901f\u9009\u578b\u3002<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6WorkerScriptXMLHttpRequestQNetworkAccessManager<\/tr>\n<tbody>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u7eaf JS \u7684\u8017\u65f6\u8ba1\u7b97&#xff0c;\u5982\u6570\u636e\u89e3\u6790\u3001\u6279\u91cf\u683c\u5f0f\u5316\u3001\u54c8\u5e0c\u8ba1\u7b97<\/td>\n<td>\u8f7b\u91cf\u7ea7 HTTP \u63a5\u53e3\u8c03\u7528&#xff0c;\u5982\u83b7\u53d6\u914d\u7f6e\u3001\u62c9\u53d6\u7b80\u5355\u5217\u8868<\/td>\n<td>\u751f\u4ea7\u7ea7\u7f51\u7edc\u5c42&#xff0c;\u5982\u7edf\u4e00\u9274\u6743\u3001\u91cd\u8bd5\u3001\u8d85\u65f6\u3001\u5e76\u53d1\u63a7\u5236<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u963b\u585e UI<\/td>\n<td>\u4e0d\u963b\u585e&#xff0c;\u8ba1\u7b97\u5728\u72ec\u7acb worker \u7ebf\u7a0b\u6267\u884c<\/td>\n<td>\u5f02\u6b65\u6a21\u5f0f\u4e0d\u963b\u585e&#xff1b;\u82e5\u8bef\u7528\u540c\u6b65\u8bf7\u6c42\u5219\u4f1a\u963b\u585e UI<\/td>\n<td>\u4e0d\u963b\u585e&#xff0c;\u57fa\u4e8e\u4e8b\u4ef6\u5faa\u73af\u4e0e\u4fe1\u53f7\u69fd\u56de\u8c03<\/td>\n<\/tr>\n<tr>\n<td>\u6570\u636e\u4f20\u9012\u65b9\u5f0f<\/td>\n<td>sendMessage \/ onMessage \u4f20\u9012\u53ef\u5e8f\u5217\u5316\u6570\u636e&#xff0c;\u6309\u503c\u590d\u5236<\/td>\n<td>\u56de\u8c03\u4e2d\u8bfb\u53d6 responseText&#xff0c;\u9700\u81ea\u884c\u89e3\u6790 JSON<\/td>\n<td>\u4fe1\u53f7\u643a\u5e26 QString \/ QByteArray&#xff0c;\u53ef\u81ea\u5b9a\u4e49\u7ed3\u6784\u4f53\u4e0e\u6a21\u578b<\/td>\n<\/tr>\n<tr>\n<td>\u80fd\u529b\u4e0a\u9650<\/td>\n<td>\u4e0d\u80fd\u8bbf\u95ee QML \u5bf9\u8c61&#xff0c;\u5355\u5b9e\u4f8b\u5355\u7ebf\u7a0b&#xff0c;\u4efb\u52a1\u6392\u961f\u6267\u884c<\/td>\n<td>\u4e0d\u652f\u6301\u8fde\u63a5\u590d\u7528\u3001\u62e6\u622a\u5668\u3001\u4e0a\u4f20\u8fdb\u5ea6\u7b49\u9ad8\u7ea7\u7279\u6027<\/td>\n<td>\u652f\u6301\u8fde\u63a5\u590d\u7528\u3001\u4ee3\u7406\u3001SSL \u914d\u7f6e\u3001\u8d85\u65f6\u91cd\u8bd5\u4e0e\u62e6\u622a\u5668<\/td>\n<\/tr>\n<tr>\n<td>\u63a8\u8350\u4f7f\u7528\u65f6\u673a<\/td>\n<td>\u8ba1\u7b97\u5bc6\u96c6\u4f46\u6570\u636e\u91cf\u4e0d\u5927&#xff0c;\u4e14\u903b\u8f91\u53ef\u5b8c\u5168\u7528 JS \u8868\u8fbe\u65f6<\/td>\n<td>\u539f\u578b\u9a8c\u8bc1\u3001\u5c11\u91cf\u7b80\u5355\u63a5\u53e3\u3001\u65e0\u9700\u7edf\u4e00\u6cbb\u7406\u7684\u573a\u666f<\/td>\n<td>\u4e2d\u5927\u578b\u9879\u76ee\u3001\u9700\u8981\u7edf\u4e00\u7f51\u7edc\u89c4\u8303\u4e0e\u53ef\u6d4b\u8bd5\u6027\u65f6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9009\u578b\u7ed3\u8bba&#xff1a;\u7eaf\u8ba1\u7b97\u7528 WorkerScript&#xff0c;\u7b80\u5355\u8bf7\u6c42\u7528 XMLHttpRequest&#xff0c;\u4e00\u65e6\u6d89\u53ca\u9274\u6743\u3001\u8d85\u65f6\u3001\u91cd\u8bd5\u3001\u5e76\u53d1\u7b49\u7edf\u4e00\u6cbb\u7406\u9700\u6c42&#xff0c;\u5c31\u5e94\u628a\u7f51\u7edc\u5c42\u4e0b\u6c89\u5230 C&#043;&#043; \u7684 QNetworkAccessManager&#xff0c;QML \u53ea\u8d1f\u8d23\u5c55\u793a\u7ed3\u679c\u3002<\/p>\n<h3>3. \u6027\u80fd\u4f18\u5316<\/h3>\n<h4>3.1 \u51cf\u5c11\u7ed1\u5b9a\u5c42\u7ea7<\/h4>\n<p>QML \u7684\u5c5e\u6027\u7ed1\u5b9a\u662f\u201c\u4f9d\u8d56\u8ffd\u8e2a &#043; \u81ea\u52a8\u91cd\u7b97\u201d\u7684\u673a\u5236\u3002\u7ed1\u5b9a\u94fe\u8d8a\u957f&#xff0c;\u4e00\u6b21\u6570\u636e\u53d8\u5316\u5f15\u53d1\u7684\u91cd\u7b97\u6b21\u6570\u8d8a\u591a&#xff0c;\u6027\u80fd\u5f00\u9500\u8d8a\u5927\u3002<\/p>\n<p>\u4e0d\u63a8\u8350\u7684\u5199\u6cd5&#xff1a;<\/p>\n<p>Item {<br \/>\n    property int base: 10<br \/>\n    property int step: 2<br \/>\n    property int factor: 3<br \/>\n    property int result: (base &#043; step) * factor<br \/>\n    property int finalValue: result * 2 &#043; base<br \/>\n    Text { text: finalValue }<br \/>\n}<\/p>\n<p>\u8fd9\u91cc finalValue \u4f9d\u8d56 result&#xff0c;result \u53c8\u4f9d\u8d56\u4e09\u4e2a\u5c5e\u6027&#xff0c;\u4efb\u4f55\u4e00\u5904\u53d8\u5316\u90fd\u4f1a\u89e6\u53d1\u591a\u7ea7\u91cd\u7b97\u3002<\/p>\n<p>\u4f18\u5316\u601d\u8def&#xff1a;<\/p>\n<ul>\n<li>\u5c3d\u91cf\u8ba9\u7ed1\u5b9a\u76f4\u63a5\u4f9d\u8d56\u6700\u7ec8\u6570\u636e\u6e90&#xff0c;\u51cf\u5c11\u4e2d\u95f4\u5c5e\u6027\u3002<\/li>\n<li>\u5bf9\u4e0d\u5e38\u53d8\u5316\u7684\u503c\u4f7f\u7528\u4e00\u6b21\u6027\u8d4b\u503c&#xff08;\u5728 Component.onCompleted \u4e2d\u8d4b\u503c&#xff09;&#xff0c;\u800c\u4e0d\u662f\u6301\u7eed\u7ed1\u5b9a\u3002<\/li>\n<li>\u5bf9\u590d\u6742\u8ba1\u7b97\u4f7f\u7528 Qt.binding() \u663e\u5f0f\u63a7\u5236\u91cd\u5efa\u65f6\u673a&#xff0c;\u6216\u6539\u4e3a\u51fd\u6570\u8c03\u7528\u6309\u9700\u8ba1\u7b97\u3002<\/li>\n<\/ul>\n<p>Item {<br \/>\n    property int base: 10<br \/>\n    property int step: 2<br \/>\n    property int factor: 3<br \/>\n    \/\/ \u76f4\u63a5\u4e00\u6b65\u7b97\u51fa&#xff0c;\u51cf\u5c11\u4e2d\u95f4\u7ed1\u5b9a<br \/>\n    property int finalValue: ((base &#043; step) * factor) * 2 &#043; base<br \/>\n    Text { text: finalValue }<br \/>\n}<\/p>\n<h4>3.2 \u4f7f\u7528Loader\u61d2\u52a0\u8f7d<\/h4>\n<p>\u9875\u9762\u4e2d\u5e76\u975e\u6240\u6709\u5185\u5bb9\u90fd\u9700\u8981\u5728\u542f\u52a8\u65f6\u521b\u5efa\u3002\u4f7f\u7528 Loader \u53ef\u4ee5\u628a\u91cd\u7ec4\u4ef6\u5ef6\u8fdf\u5230\u771f\u6b63\u9700\u8981\u65f6\u518d\u5b9e\u4f8b\u5316&#xff0c;\u663e\u8457\u7f29\u77ed\u9996\u5c4f\u65f6\u95f4\u3002<\/p>\n<p>import QtQuick 2.15<\/p>\n<p>Item {<br \/>\n    width: 800<br \/>\n    height: 600<\/p>\n<p>    Loader {<br \/>\n        id: heavyLoader<br \/>\n        anchors.fill: parent<br \/>\n        active: false          \/\/ \u521d\u59cb\u4e0d\u52a0\u8f7d<br \/>\n        asynchronous: true     \/\/ \u5f02\u6b65\u52a0\u8f7d&#xff0c;\u907f\u514d\u5361\u987f<br \/>\n        source: &#034;HeavyPanel.qml&#034;<br \/>\n    }<\/p>\n<p>    Button {<br \/>\n        text: &#034;\u6253\u5f00\u9762\u677f&#034;<br \/>\n        onClicked: heavyLoader.active &#061; true<br \/>\n    }<br \/>\n}<\/p>\n<p>\u4f7f\u7528\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>active: false \u65f6 Loader \u4e0d\u521b\u5efa\u5185\u5bb9&#xff0c;\u5185\u5b58\u5360\u7528\u66f4\u4f4e\u3002<\/li>\n<li>asynchronous: true \u8ba9\u7ec4\u4ef6\u5728\u540e\u53f0\u7ebf\u7a0b\u52a0\u8f7d&#xff0c;\u9002\u5408\u5927\u9875\u9762\u3002<\/li>\n<li>\u901a\u8fc7 item \u5c5e\u6027\u8bbf\u95ee\u5df2\u52a0\u8f7d\u5bf9\u8c61&#xff0c;\u6ce8\u610f\u5224\u7a7a\u3002<\/li>\n<li>\u5bf9\u9891\u7e41\u5207\u6362\u7684\u9875\u9762&#xff0c;\u53ef\u4ee5\u914d\u5408 sourceComponent \u590d\u7528\u7ec4\u4ef6\u5b9a\u4e49\u3002<\/li>\n<\/ul>\n<h4>3.3 \u907f\u514ddelegate\u91cd\u8ba1\u7b97<\/h4>\n<p>ListView \/ GridView \u7684 delegate \u4f1a\u88ab\u5927\u91cf\u521b\u5efa\u548c\u590d\u7528&#xff0c;delegate \u4e2d\u7684\u4efb\u4f55\u91cd\u8ba1\u7b97\u90fd\u4f1a\u88ab\u653e\u5927\u6210\u6027\u80fd\u95ee\u9898\u3002<\/p>\n<p>\u5e38\u89c1\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u5728 delegate \u91cc\u8c03\u7528\u51fd\u6570\u505a\u5b57\u7b26\u4e32\u62fc\u63a5\u3001\u683c\u5f0f\u5316\u3001\u6392\u5e8f\u3002<\/li>\n<li>\u5728 delegate \u91cc\u521b\u5efa\u5927\u91cf\u4e34\u65f6\u5bf9\u8c61\u6216\u8fdb\u884c\u590d\u6742\u7ed1\u5b9a\u3002<\/li>\n<li>\u5728 delegate \u91cc\u4f7f\u7528 console.log \u8c03\u8bd5\u8f93\u51fa\u3002<\/li>\n<\/ul>\n<p>\u4f18\u5316\u505a\u6cd5&#xff1a;\u628a\u8ba1\u7b97\u524d\u7f6e\u5230\u6a21\u578b\u5c42&#xff0c;delegate \u53ea\u505a\u5c55\u793a\u3002<\/p>\n<p>\/\/ \u4e0d\u63a8\u8350&#xff1a;delegate \u4e2d\u505a\u683c\u5f0f\u5316<br \/>\nListView {<br \/>\n    model: 1000<br \/>\n    delegate: Text {<br \/>\n        text: &#034;\u7b2c &#034; &#043; index &#043; &#034; \u9879&#xff0c;\u957f\u5ea6&#xff1a;&#034; &#043; (index * 2 &#043; 1).toString().length<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u63a8\u8350&#xff1a;\u6a21\u578b\u5c42\u9884\u5148\u8ba1\u7b97\u597d\u5c55\u793a\u5b57\u6bb5<br \/>\nListModel {<br \/>\n    id: dataModel<br \/>\n    Component.onCompleted: {<br \/>\n        for (var i &#061; 0; i &lt; 1000; i&#043;&#043;) {<br \/>\n            append({ displayText: &#034;\u7b2c &#034; &#043; i &#043; &#034; \u9879&#034; })<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>ListView {<br \/>\n    model: dataModel<br \/>\n    delegate: Text { text: model.displayText }<br \/>\n}<\/p>\n<p>\u6b64\u5916&#xff0c;delegate \u5e94\u5c3d\u91cf\u6241\u5e73&#xff0c;\u51cf\u5c11\u5d4c\u5957\u5c42\u7ea7&#xff1b;\u5bf9\u56fa\u5b9a\u5c3a\u5bf8\u7684\u5217\u8868\u9879\u663e\u5f0f\u8bbe\u7f6e width \/ height&#xff0c;\u907f\u514d\u5e03\u5c40\u53cd\u590d\u8ba1\u7b97\u3002<\/p>\n<h3>4. \u5de5\u7a0b\u5316\u5b9e\u8df5<\/h3>\n<h4>4.1 QML\u6a21\u5757\u5212\u5206<\/h4>\n<p>\u968f\u7740\u9879\u76ee\u53d8\u5927&#xff0c;\u628a\u6240\u6709 QML \u6587\u4ef6\u5806\u5728\u4e00\u4e2a\u76ee\u5f55\u91cc\u4f1a\u8fc5\u901f\u5931\u63a7\u3002\u63a8\u8350\u6309\u804c\u8d23\u5212\u5206\u6a21\u5757&#xff1a;<\/p>\n<p>project\/<br \/>\n\u251c\u2500\u2500 main.qml<br \/>\n\u251c\u2500\u2500 qml\/<br \/>\n\u2502   \u251c\u2500\u2500 components\/      # \u901a\u7528\u57fa\u7840\u7ec4\u4ef6&#xff08;Button\u3001Card\u3001Dialog&#xff09;<br \/>\n\u2502   \u251c\u2500\u2500 pages\/           # \u9875\u9762\u7ea7\u7ec4\u4ef6<br \/>\n\u2502   \u251c\u2500\u2500 models\/          # \u6570\u636e\u6a21\u578b\u4e0e\u4e1a\u52a1\u903b\u8f91<br \/>\n\u2502   \u2514\u2500\u2500 utils\/           # \u5de5\u5177\u51fd\u6570\u4e0e\u5e38\u91cf<br \/>\n\u2514\u2500\u2500 resources.qrc<\/p>\n<p>\u5212\u5206\u539f\u5219&#xff1a;<\/p>\n<ul>\n<li>components \u53ea\u4f9d\u8d56 QtQuick \u57fa\u7840\u6a21\u5757&#xff0c;\u4e0d\u4f9d\u8d56\u5177\u4f53\u4e1a\u52a1\u3002<\/li>\n<li>pages \u7ec4\u5408 components \u4e0e models&#xff0c;\u8d1f\u8d23\u754c\u9762\u7f16\u6392\u3002<\/li>\n<li>models \u5c3d\u91cf\u4e0e UI \u89e3\u8026&#xff0c;\u4fbf\u4e8e\u5355\u5143\u6d4b\u8bd5\u548c\u66ff\u6362\u3002<\/li>\n<\/ul>\n<h4>4.2 Qmldir<\/h4>\n<p>qmldir \u6587\u4ef6\u7528\u4e8e\u58f0\u660e\u4e00\u4e2a\u76ee\u5f55\u662f\u4e00\u4e2a QML \u6a21\u5757&#xff0c;\u5305\u542b\u6a21\u5757\u540d\u3001\u7248\u672c\u548c\u7ec4\u4ef6\u6620\u5c04\u3002<\/p>\n<p>module MyApp.Components<br \/>\nButton 1.0 Button.qml<br \/>\nCard 1.0 Card.qml<br \/>\nDialog 1.0 Dialog.qml<\/p>\n<p>\u914d\u5408 import \u4f7f\u7528&#xff1a;<\/p>\n<p>import QtQuick 2.15<br \/>\nimport MyApp.Components 1.0<\/p>\n<p>Card {<br \/>\n    Button { text: &#034;\u786e\u5b9a&#034; }<br \/>\n}<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/p>\n<ul>\n<li>\u6a21\u5757\u540d\u5efa\u8bae\u4f7f\u7528\u53cd\u5411\u57df\u540d\u98ce\u683c&#xff0c;\u907f\u514d\u4e0e\u7b2c\u4e09\u65b9\u6a21\u5757\u51b2\u7a81\u3002<\/li>\n<li>qmldir \u4e2d\u7684\u7248\u672c\u53f7\u8981\u4e0e import \u8bed\u53e5\u4e00\u81f4\u3002<\/li>\n<li>\u5982\u679c\u6a21\u5757\u5305\u542b C&#043;&#043; \u7c7b\u578b&#xff0c;\u9700\u8981\u5728 C&#043;&#043; \u4fa7\u7528 qmlRegisterType \u6ce8\u518c&#xff0c;\u5e76\u5728 qmldir \u4e2d\u58f0\u660e plugin \u6216 classname\u3002<\/li>\n<\/ul>\n<h4>4.3 \u8d44\u6e90\u6253\u5305<\/h4>\n<p>QML \u6587\u4ef6\u3001\u56fe\u7247\u3001\u5b57\u4f53\u7b49\u8d44\u6e90\u5efa\u8bae\u7edf\u4e00\u6253\u5305\u8fdb .qrc \u8d44\u6e90\u6587\u4ef6&#xff0c;\u968f\u53ef\u6267\u884c\u6587\u4ef6\u4e00\u8d77\u53d1\u5e03&#xff0c;\u907f\u514d\u8def\u5f84\u4e22\u5931\u548c\u5916\u90e8\u7be1\u6539\u3002<\/p>\n<p>&lt;RCC&gt;<br \/>\n    &lt;qresource prefix&#061;&#034;\/&#034;&gt;<br \/>\n        &lt;file&gt;main.qml&lt;\/file&gt;<br \/>\n        &lt;file&gt;qml\/components\/Button.qml&lt;\/file&gt;<br \/>\n        &lt;file&gt;qml\/pages\/HomePage.qml&lt;\/file&gt;<br \/>\n        &lt;file&gt;images\/logo.png&lt;\/file&gt;<br \/>\n    &lt;\/qresource&gt;<br \/>\n&lt;\/RCC&gt;<\/p>\n<p>\u5728 .pro \u6216 CMakeLists.txt \u4e2d\u5f15\u5165\u8d44\u6e90\u6587\u4ef6\u540e&#xff0c;QML \u4e2d\u901a\u8fc7 qrc:\/ \u524d\u7f00\u8bbf\u95ee&#xff1a;<\/p>\n<p>Image { source: &#034;qrc:\/images\/logo.png&#034; }<\/p>\n<p>\u5b9e\u8df5\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\u5927\u56fe\u7247\u8003\u8651\u538b\u7f29\u6216\u4f7f\u7528 sourceSize \u9650\u5236\u89e3\u7801\u5c3a\u5bf8\u3002<\/li>\n<li>\u5f00\u53d1\u9636\u6bb5\u53ef\u4ee5\u7528\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84\u52a0\u5feb\u8fed\u4ee3&#xff0c;\u53d1\u5e03\u65f6\u7edf\u4e00\u5207\u6362\u5230 qrc\u3002<\/li>\n<li>\u8d44\u6e90\u8f83\u591a\u65f6\u6309\u6a21\u5757\u62c6\u5206\u591a\u4e2a qrc \u6587\u4ef6&#xff0c;\u4fbf\u4e8e\u7ef4\u62a4\u3002<\/li>\n<\/ul>\n<h4>4.4 \u56fd\u9645\u5316\u7ffb\u8bd1<\/h4>\n<p>QML \u4e2d\u4f7f\u7528 qsTr() \u5305\u88f9\u9700\u8981\u7ffb\u8bd1\u7684\u5b57\u7b26\u4e32&#xff0c;Qt \u4f1a\u5728\u8fd0\u884c\u65f6\u6839\u636e\u5f53\u524d\u8bed\u8a00\u52a0\u8f7d\u5bf9\u5e94\u7684\u7ffb\u8bd1\u6587\u4ef6\u3002<\/p>\n<p>import QtQuick 2.15<\/p>\n<p>Text {<br \/>\n    text: qsTr(&#034;Welcome to QML&#034;)<br \/>\n}<\/p>\n<p>Button {<br \/>\n    text: qsTr(&#034;Confirm&#034;)<br \/>\n}<\/p>\n<p>\u5e26\u53c2\u6570\u7684\u7ffb\u8bd1&#xff1a;<\/p>\n<p>Text {<br \/>\n    text: qsTr(&#034;Found %1 items&#034;).arg(count)<br \/>\n}<\/p>\n<p>\u7ffb\u8bd1\u6d41\u7a0b&#xff1a;<\/p>\n<li>\u5728 .pro \u4e2d\u914d\u7f6e TRANSLATIONS &#043;&#061; app_zh_CN.ts\u3002<\/li>\n<li>\u4f7f\u7528 lupdate \u626b\u63cf\u6e90\u7801&#xff0c;\u751f\u6210\u6216\u66f4\u65b0 .ts \u6587\u4ef6\u3002<\/li>\n<li>\u7528 Qt Linguist \u7ffb\u8bd1 .ts \u6587\u4ef6\u3002<\/li>\n<li>\u4f7f\u7528 lrelease \u751f\u6210 .qm \u6587\u4ef6&#xff0c;\u5e76\u5728\u7a0b\u5e8f\u4e2d\u901a\u8fc7 QTranslator \u52a0\u8f7d\u3002<\/li>\n<p>\/\/ main.cpp \u4e2d\u52a0\u8f7d\u7ffb\u8bd1<br \/>\n#include &lt;QTranslator&gt;<\/p>\n<p>QTranslator translator;<br \/>\nif (translator.load(&#034;:\/i18n\/app_zh_CN.qm&#034;)) {<br \/>\n    app.installTranslator(&amp;translator);<br \/>\n}<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;<\/p>\n<ul>\n<li>\u4e0d\u8981\u5728 qsTr() \u4e2d\u4f7f\u7528\u53d8\u91cf\u62fc\u63a5&#xff0c;\u5426\u5219\u7ffb\u8bd1\u5de5\u5177\u65e0\u6cd5\u63d0\u53d6\u5b8c\u6574\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5bf9\u52a8\u6001\u8bed\u8a00\u5207\u6362&#xff0c;\u9700\u8981\u91cd\u65b0\u52a0\u8f7d\u7ffb\u8bd1\u5e76\u5237\u65b0\u754c\u9762\u6587\u672c\u3002<\/li>\n<li>\u6570\u5b57\u3001\u65e5\u671f\u3001\u8d27\u5e01\u683c\u5f0f\u5316\u5efa\u8bae\u4f7f\u7528 Qt.locale() \u76f8\u5173 API\u3002<\/li>\n<\/ul>\n<h3>5. \u603b\u7ed3<\/h3>\n<p>\u672c\u6587\u4ece\u4e09\u4e2a\u7ef4\u5ea6\u68b3\u7406\u4e86 QML \u8fdb\u9636\u7684\u5173\u952e\u80fd\u529b&#xff1a;<\/p>\n<ul>\n<li>\u5f02\u6b65\u4e0e\u7f51\u7edc&#xff1a;WorkerScript \u5904\u7406\u7eaf JS \u8ba1\u7b97&#xff0c;XMLHttpRequest \u5e94\u5bf9\u8f7b\u91cf\u8bf7\u6c42&#xff0c;QNetworkAccessManager \u6784\u5efa\u751f\u4ea7\u7ea7\u7f51\u7edc\u5c42\u3002<\/li>\n<li>\u6027\u80fd\u4f18\u5316&#xff1a;\u51cf\u5c11\u7ed1\u5b9a\u5c42\u7ea7\u3001\u7528 Loader \u61d2\u52a0\u8f7d\u3001\u628a\u91cd\u8ba1\u7b97\u79fb\u51fa delegate\u3002<\/li>\n<li>\u5de5\u7a0b\u5316&#xff1a;\u6309\u804c\u8d23\u5212\u5206\u6a21\u5757\u3001\u7528 qmldir \u58f0\u660e\u6a21\u5757\u3001\u7528 qrc \u6253\u5305\u8d44\u6e90\u3001\u7528 qsTr() \u652f\u6301\u56fd\u9645\u5316\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u80fd\u529b\u5355\u72ec\u770b\u90fd\u4e0d\u590d\u6742&#xff0c;\u4f46\u7ec4\u5408\u8d77\u6765\u51b3\u5b9a\u4e86\u9879\u76ee\u80fd\u5426\u957f\u671f\u7ef4\u62a4\u3002\u5efa\u8bae\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5148\u843d\u5730\u5176\u4e2d\u4e00\u4e24\u70b9&#xff0c;\u6bd4\u5982\u5148\u628a\u7f51\u7edc\u5c42\u4e0b\u6c89\u5230 C&#043;&#043;&#xff0c;\u518d\u9010\u6b65\u5f15\u5165\u6a21\u5757\u5212\u5206\u548c\u56fd\u9645\u5316&#xff0c;\u5faa\u5e8f\u6e10\u8fdb\u5730\u5b8c\u6210\u4ece\u201c\u80fd\u8dd1\u201d\u5230\u201c\u8dd1\u5f97\u597d\u201d\u7684\u8f6c\u53d8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5f15\u8a00\u5728 QML \u8fdb\u9636&#xff08;\u4e00&#xff09;\u4e2d&#xff0c;\u6211\u4eec\u5df2\u7ecf\u638c\u63e1\u4e86\u5c5e\u6027\u7ed1\u5b9a\u3001\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u3001\u72b6\u6001\u4e0e\u52a8\u753b\u3001\u6a21\u578b\u89c6\u56fe\u7b49\u57fa\u7840\u80fd\u529b\u3002\u6b64\u65f6\u4f60\u5927\u6982\u7387\u5df2\u7ecf\u80fd\u5199\u51fa\u4e00\u4e2a\u201c\u80fd\u8dd1\u8d77\u6765\u201d\u7684\u754c\u9762&#xff0c;\u4f46\u771f\u6b63\u8fdb\u5165\u9879\u76ee\u5f00\u53d1\u540e&#xff0c;\u95ee\u9898\u4f1a\u96c6\u4e2d\u51fa\u73b0\u5728\u4e09\u4e2a\u65b9\u5411&#xff1a;\u5f02\u6b65\u4e0e\u7f51\u7edc&#xff1a;\u754c\u9762\u5361\u987f\u3001\u8bf7\u6c42\u963b\u585e UI \u7ebf\u7a0b\u3001\u8de8\u7ebf\u7a0b\u6570\u636e\u4f20\u9012\u51fa\u9519\u3002\u6027\u80fd\u4f18\u5316&#xff1a;\u7ed1\u5b9a\u5c42\u7ea7\u8fc7\u6df1\u3001\u5217\u8868\u6eda\u52a8\u6389\u5e27\u3001delegate \u91cc\u505a\u91cd\u8ba1\u7b97\u3002\u5de5\u7a0b\u5316&#xff1a;\u4ee3\u7801\u8d8a\u5199\u8d8a\u4e71\u3001\u6a21<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5664,218,56,78],"topic":[],"class_list":["post-120483","post","type-post","status-publish","format-standard","hentry","category-server","tag-qml","tag-qt","tag-56","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730 - \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\/120483.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1. \u5f15\u8a00\u5728 QML \u8fdb\u9636&#xff08;\u4e00&#xff09;\u4e2d&#xff0c;\u6211\u4eec\u5df2\u7ecf\u638c\u63e1\u4e86\u5c5e\u6027\u7ed1\u5b9a\u3001\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u3001\u72b6\u6001\u4e0e\u52a8\u753b\u3001\u6a21\u578b\u89c6\u56fe\u7b49\u57fa\u7840\u80fd\u529b\u3002\u6b64\u65f6\u4f60\u5927\u6982\u7387\u5df2\u7ecf\u80fd\u5199\u51fa\u4e00\u4e2a\u201c\u80fd\u8dd1\u8d77\u6765\u201d\u7684\u754c\u9762&#xff0c;\u4f46\u771f\u6b63\u8fdb\u5165\u9879\u76ee\u5f00\u53d1\u540e&#xff0c;\u95ee\u9898\u4f1a\u96c6\u4e2d\u51fa\u73b0\u5728\u4e09\u4e2a\u65b9\u5411&#xff1a;\u5f02\u6b65\u4e0e\u7f51\u7edc&#xff1a;\u754c\u9762\u5361\u987f\u3001\u8bf7\u6c42\u963b\u585e UI \u7ebf\u7a0b\u3001\u8de8\u7ebf\u7a0b\u6570\u636e\u4f20\u9012\u51fa\u9519\u3002\u6027\u80fd\u4f18\u5316&#xff1a;\u7ed1\u5b9a\u5c42\u7ea7\u8fc7\u6df1\u3001\u5217\u8868\u6eda\u52a8\u6389\u5e27\u3001delegate \u91cc\u505a\u91cd\u8ba1\u7b97\u3002\u5de5\u7a0b\u5316&#xff1a;\u4ee3\u7801\u8d8a\u5199\u8d8a\u4e71\u3001\u6a21\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/120483.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-31T11:48:28+00:00\" \/>\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=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120483.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/120483.html\",\"name\":\"QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-31T11:48:28+00:00\",\"dateModified\":\"2026-10-31T11:48:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/120483.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/120483.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120483.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730\"}]},{\"@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\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730 - \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\/120483.html","og_locale":"zh_CN","og_type":"article","og_title":"QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1. \u5f15\u8a00\u5728 QML \u8fdb\u9636&#xff08;\u4e00&#xff09;\u4e2d&#xff0c;\u6211\u4eec\u5df2\u7ecf\u638c\u63e1\u4e86\u5c5e\u6027\u7ed1\u5b9a\u3001\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u3001\u72b6\u6001\u4e0e\u52a8\u753b\u3001\u6a21\u578b\u89c6\u56fe\u7b49\u57fa\u7840\u80fd\u529b\u3002\u6b64\u65f6\u4f60\u5927\u6982\u7387\u5df2\u7ecf\u80fd\u5199\u51fa\u4e00\u4e2a\u201c\u80fd\u8dd1\u8d77\u6765\u201d\u7684\u754c\u9762&#xff0c;\u4f46\u771f\u6b63\u8fdb\u5165\u9879\u76ee\u5f00\u53d1\u540e&#xff0c;\u95ee\u9898\u4f1a\u96c6\u4e2d\u51fa\u73b0\u5728\u4e09\u4e2a\u65b9\u5411&#xff1a;\u5f02\u6b65\u4e0e\u7f51\u7edc&#xff1a;\u754c\u9762\u5361\u987f\u3001\u8bf7\u6c42\u963b\u585e UI \u7ebf\u7a0b\u3001\u8de8\u7ebf\u7a0b\u6570\u636e\u4f20\u9012\u51fa\u9519\u3002\u6027\u80fd\u4f18\u5316&#xff1a;\u7ed1\u5b9a\u5c42\u7ea7\u8fc7\u6df1\u3001\u5217\u8868\u6eda\u52a8\u6389\u5e27\u3001delegate \u91cc\u505a\u91cd\u8ba1\u7b97\u3002\u5de5\u7a0b\u5316&#xff1a;\u4ee3\u7801\u8d8a\u5199\u8d8a\u4e71\u3001\u6a21","og_url":"https:\/\/www.wsisp.com\/helps\/120483.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-31T11:48:28+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/120483.html","url":"https:\/\/www.wsisp.com\/helps\/120483.html","name":"QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-31T11:48:28+00:00","dateModified":"2026-10-31T11:48:28+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/120483.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/120483.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/120483.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"QML\u8fdb\u9636\u5b9e\u6218(\u4e8c)\uff1a\u5f02\u6b65\u7f51\u7edc\u3001\u6027\u80fd\u4f18\u5316\u4e0e\u5de5\u7a0b\u5316\u843d\u5730"}]},{"@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\/120483","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=120483"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/120483\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=120483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=120483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=120483"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=120483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}