{"id":212,"date":"2021-11-21T13:50:01","date_gmt":"2021-11-21T13:50:01","guid":{"rendered":"http:\/\/47.103.123.166\/?p=212"},"modified":"2021-11-21T13:50:01","modified_gmt":"2021-11-21T13:50:01","slug":"qt-%e4%bf%a1%e5%8f%b7%e4%b8%8e%e6%a7%bd%e7%9a%84%e5%8e%9f%e7%90%86","status":"publish","type":"post","link":"http:\/\/47.103.123.166\/?p=212","title":{"rendered":"Qt\u2014\u2014\u4fe1\u53f7\u4e0e\u69fd\u7684\u539f\u7406"},"content":{"rendered":"<h2>QT\u5143\u5bf9\u8c61\u7cfb\u7edf<\/h2>\n<p><font face=\"\u6977\u4f53\">QT\u5143\u5bf9\u8c61\u7cfb\u7edf\u7684\u4e09\u4e2a\u91cd\u8981\u7ec4\u6210\u5305\u62ec\uff1a<br \/>\n1\uff09QObject\u7c7b\uff08\u6240\u6709\u4f7f\u7528\u5143\u5bf9\u8c61\u7cfb\u7edf\u7684\u57fa\u7c7b\uff09<br \/>\n2\uff09Q_OBJECT\uff08\u6240\u5728\u7c7b\u53ef\u4ee5\u4f7f\u7528\u5143\u5bf9\u8c61\u7279\u6027\uff09<br \/>\n3\uff09MOC\uff08meta-object-compiler\uff0c\u5143\u5bf9\u8c61\u7f16\u8bd1\u5668\uff0c\u9884\u5904\u7406\u5305\u542bQ_OBJECT\u5b8f\u7684\u7c7b\uff09<\/p>\n<h2>\u6574\u4f53\u7684\u7f16\u8bd1\u8fc7\u7a0b<\/h2>\n<p><font face=\"\u6977\u4f53\">\u9996\u5148\u8fdb\u884cMOC\u9884\u5904\u7406\uff0cQ_OBJECT\u5b8f\u5c06\u5c55\u5f00\u548c\u81ea\u52a8\u751f\u6210\u4e00\u4e9b\u53d8\u91cf\u5b9a\u4e49\u3001\u51fd\u6570\u58f0\u660e\u7b49\u4ee3\u7801\uff0c\u540c\u65f6\u751f\u6210moc_xxx.cpp\uff0c\u4e4b\u540e\u8fdb\u884c\u666e\u901a\u7f16\u8bd1\u3002<\/p>\n<h2>\u4fe1\u53f7\u4e0e\u69fd\u7684\u9884\u5904\u7406\uff1a\u770b\u6210\u666e\u901a\u51fd\u6570<\/h2>\n<p><font face=\"\u6977\u4f53\">1\uff09\u5728MOC\u9884\u5904\u7406\u8fc7\u7a0b\u4e2d\uff0cQ_OBJECT\u5c06\u5c55\u5f00\uff0c\u7c7b\u4e2d\u5b9a\u4e49\u7684\u4fe1\u53f7\u548c\u69fd\u4e5f\u88ab\u5904\u7406\u3002<br \/>\n2\uff09\u5904\u7406\u540e\u4f1a\u5c06\u4fe1\u53f7\u4e0e\u69fd\u90fd\u4f5c\u4e3a\u53ef\u56de\u8c03\u7684\u51fd\u6570\uff0c\u6839\u636eid\u8c03\u7528\uff0c\u51fd\u6570\u53ca\u5176id\u7684\u5b9a\u4e49\u5728Q_OBJECT\u5c55\u5f00\u7684\u51fd\u6570qt_static_metacall\u4e2d\uff0c\u5982\u5b9e\u4f8b1<br \/>\n3\uff09\u5176\u533a\u522b\u662f\u5728\u4e0d\u540c\u7684\u5173\u952e\u5b57\uff08signals\uff0cslots\uff09\u58f0\u660e\u4e0b\uff0c\u4fe1\u53f7\u7684\u5b9e\u73b0\u7531moc\u5b8c\u6210\uff0c\u5982\u5b9e\u4f8b2\uff0c\u800c\u69fd\u51fd\u6570\u7684\u5b9e\u73b0\u9700\u8981\u81ea\u5df1\u5b8c\u6210\u3002<\/p>\n<h2>\u4fe1\u53f7\u4e0e\u69fd\u7684\u5173\u8054\uff1a\u6784\u5efaConnection\u5bf9\u8c61<\/h2>\n<p><font face=\"\u6977\u4f53\">1\uff09connect\u51fd\u6570\u6784\u9020\u4e86\u4e00\u4e2aConnection\u5bf9\u8c61\uff0c\u5c06\u63a5\u53d1\u5bf9\u8c61\u3001\u51fd\u6570\uff08\u4fe1\u53f7\u69fd\uff09\u7684id\u3001\u8fde\u63a5\u65b9\u5f0f\u7b49\u4fdd\u5b58\u5728\u53d1\u9001\u8005\u5185\u5b58\uff0c\u5982\u5b9e\u4f8b3\u3002<br \/>\n2\uff09\u800c\u53d1\u9001\u8005\u5c06\u5185\u5b58\u4e2d\u7684Connection\u5bf9\u8c61\u4fdd\u5b58\u5728QObjectConnectionListVector\u4e2d\uff0cQObjectConnectionListVector\u662f\u4e2a\u6570\u7ec4\uff0c\u901a\u8fc7\u4fe1\u53f7id\u7d22\u5f15\u3002<br \/>\n3\uff09\u4e00\u4e2a\u4fe1\u53f7\u53ef\u4ee5\u8fde\u63a5\u591a\u4e2a\u69fd\uff0c\u5219\u4fe1\u53f7id\u7d22\u5f15\u7684\u5185\u5bb9\u662f\u6570\u7ec4\u67d0\u4e2a\u4f4d\u7f6e\u7684ConnectionList\u3002<\/p>\n<h2>\u4fe1\u53f7\u7684\u89e6\u53d1\u4e0e\u69fd\u7684\u6267\u884c\uff1a\u6267\u884c\u51fd\u6570\u56de\u8c03<\/h2>\n<p><font face=\"\u6977\u4f53\">1\uff09\u6267\u884cemit\uff0c\u5219\u76f8\u5f53\u4e8e\u8c03\u7528QMetaObject::activate\u51fd\u6570\uff0c\u6b64\u65f6\u901a\u8fc7\u4fe1\u53f7id\uff0c\u83b7\u5f97ConnectionList\u3002<br \/>\n2\uff09\u5bf9\u4e8e\u76f4\u8fde\u7684\u4fe1\u53f7\u69fd\uff0c\u4f1a\u76f4\u63a5\u6267\u884c\u69fd\u51fd\u6570id\u5bf9\u5e94\u7684\u51fd\u6570\uff1b<br \/>\n3\uff09\u5bf9\u4e8e\u961f\u5217\u8fde\u63a5\u7684\u69fd\u51fd\u6570\uff0c\u5c06\u901a\u8fc7QMetaObject::queued_activate\uff0c\u629b\u51faQMetaCallEvent\u4e8b\u4ef6\uff0c\u628aConnection\u6254\u5230\u63a5\u53d7\u8005\u6240\u5728\u7ebf\u7a0b\uff0c\u5728\u63a5\u53d7\u8005\u6240\u5728\u7ebf\u7a0b\u7684\u4e8b\u4ef6\u5faa\u73af\u4e2d\u6267\u884c\uff0c\u5982\u5b9e\u4f8b4\u3002<\/p>\n<h2>\u53c2\u8003<\/h2>\n<p>1\u3001<a href=\"https:\/\/www.cnblogs.com\/swarmbees\/p\/10816139.html\"><a href=\"https:\/\/www.cnblogs.com\/swarmbees\/p\/10816139.html\">https:\/\/www.cnblogs.com\/swarmbees\/p\/10816139.html<\/a><\/a><\/p>\n<h2>\u5b9e\u4f8b<\/h2>\n<p><font face=\"\u6977\u4f53\">\u5b9e\u4f8b1<\/p>\n<pre><code class=\"language-cpp\">void MasterConsole::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n    if (_c == QMetaObject::InvokeMetaMethod) {\n        auto *_t = static_cast&lt;MasterConsole *&gt;(_o);\n        Q_UNUSED(_t)\n        switch (_id) {\n        case 0: _t-&gt;publishOrder((*reinterpret_cast&lt; int(*)&gt;(_a[1])),(*reinterpret_cast&lt; QString(*)&gt;(_a[2]))); break;\n        case 1: _t-&gt;toBuilder(); break;\n        case 2: _t-&gt;toDeleter(); break;\n        case 3: _t-&gt;on_btnTestStartDistribution_clicked(); break;\n        default: ;\n        }\n\/\/...\n}<\/code><\/pre>\n<p><font face=\"\u6977\u4f53\">\u5b9e\u4f8b2<\/p>\n<pre><code class=\"language-cpp\">\/\/ SIGNAL 1\nvoid MasterConsole::toBuilder()\n{\n    QMetaObject::activate(this, &amp;staticMetaObject, 1, nullptr);\n}<\/code><\/pre>\n<p><font face=\"\u6977\u4f53\">\u5b9e\u4f8b3<\/p>\n<pre><code class=\"language-cpp\">QScopedPointer&lt;QObjectPrivate::Connection&gt; c(new QObjectPrivate::Connection);\nc-&gt;sender = s;                              \/\/\u53d1\u9001\u8005\nc-&gt;signal_index = signal_index;             \/\/\u4fe1\u53f7\u7d22\u5f15\nc-&gt;receiver = r;                            \/\/\u63a5\u6536\u8005\nc-&gt;method_relative = method_index;          \/\/\u69fd\u51fd\u6570\u7d22\u5f15\nc-&gt;method_offset = method_offset;           \/\/\u69fd\u51fd\u6570\u504f\u79fb \u4e3b\u8981\u662f\u533a\u522b\u4e8e\u591a\u4e2a\u4fe1\u53f7\nc-&gt;connectionType = type;                   \/\/\u8fde\u63a5\u7c7b\u578b\nc-&gt;isSlotObject = false;                    \/\/\u662f\u5426\u662f\u69fd\u5bf9\u8c61 \u9ed8\u8ba4\u662ftrue\nc-&gt;argumentTypes.store(types);              \/\/\u53c2\u6570\u7c7b\u578b\nc-&gt;nextConnectionList = 0;                  \/\/\u6307\u5411\u4e0b\u4e2a\u8fde\u63a5\u5bf9\u8c61\nc-&gt;callFunction = callFunction;             \/\/\u9759\u6001\u56de\u8c03\u51fd\u6570\uff0c\u4e5f\u5c31\u662fqt_static_metacall\n\nQObjectPrivate::get(s)-&gt;addConnection(signal_index, c.data());<\/code><\/pre>\n<p><font face=\"\u6977\u4f53\">\u5b9e\u4f8b4<\/p>\n<pre><code class=\"language-cpp\">void QMetaObject::activate(QObject *sender, int signalOffset ......)\n{\n    . . . . . .\n    \/\/\u53d1\u9001\u65b9\u548c\u63a5\u6536\u65b9\u662f\u5426\u5728\u540c\u4e00\u4e2a\u7ebf\u7a0b\u4e2d\n        const bool receiverInSameThread =  currentThreadId == receiver-&gt;d_func()-&gt;threadData-&gt;threadId;\n         \/\/\u51b3\u5b9a\u8fde\u63a5\u7acb\u523b\u53d1\u9001\u8fd8\u662f\u52a0\u5165\u4e8b\u4ef6\u961f\u5217\n            if ((c-&gt;connectionType == Qt::AutoConnection &amp;&amp; !receiverInSameThread)\n                || (c-&gt;connectionType == Qt::QueuedConnection))\n                {\n                queued_activate(sender, signal_index, c, argv ? argv : empty_argv, locker);\n                continue;\n            } else if\n\/\/...\n}\n\nstatic void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv,  QMutexLocker &amp;locker)\n{\n  ...\n     QMetaCallEvent *ev = c-&gt;isSlotObject ?\n     new QMetaCallEvent(c-&gt;slotObj, sender, signal, nargs, types, args) :\n     new QMetaCallEvent(c-&gt;method_offset, c-&gt;method_relative, c-&gt;callFunction, \n                        sender, signal, nargs, types, args);\n\n    \/\/post\u4e8b\u4ef6\u5230\u63a5\u6536\u8005\u6240\u5c5e\u7ebf\u7a0b\u7684QThreadData::postEventList\u961f\u5217\u4e2d\n     QCoreApplication::postEvent(c-&gt;receiver, ev);\n  ...\n}<\/code><\/pre>\n<p><font face=\"\u6977\u4f53\">\u5b9e\u4f8b5\uff1a\u4e00\u4e2a\u7b80\u5355\u7684moc_xxx.cpp\u6587\u4ef6<\/p>\n<pre><code class=\"language-cpp\">\/****************************************************************************\n** Meta object code from reading C++ file 'masterconsole.h'\n**\n** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.6)\n**\n** WARNING! All changes made in this file will be lost!\n*****************************************************************************\/\n\n#include \"..\/..\/SandTable_MasterConsole\/masterconsole.h\"\n#include &lt;QtCore\/qbytearray.h&gt;\n#include &lt;QtCore\/qmetatype.h&gt;\n#if !defined(Q_MOC_OUTPUT_REVISION)\n#error \"The header file 'masterconsole.h' doesn't include &lt;QObject&gt;.\"\n#elif Q_MOC_OUTPUT_REVISION != 67\n#error \"This file was generated using the moc from 5.12.6. It\"\n#error \"cannot be used with the include files from this version of Qt.\"\n#error \"(The moc has changed too much.)\"\n#endif\n\nQT_BEGIN_MOC_NAMESPACE\nQT_WARNING_PUSH\nQT_WARNING_DISABLE_DEPRECATED\nstruct qt_meta_stringdata_MasterConsole_t {\n    QByteArrayData data[12];\n    char stringdata0[235];\n};\n#define QT_MOC_LITERAL(idx, ofs, len) \\\n    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \\\n    qptrdiff(offsetof(qt_meta_stringdata_MasterConsole_t, stringdata0) + ofs \\\n        - idx * sizeof(QByteArrayData)) \\\n    )\nstatic const qt_meta_stringdata_MasterConsole_t qt_meta_stringdata_MasterConsole = {\n    {\nQT_MOC_LITERAL(0, 0, 13), \/\/ \"MasterConsole\"\nQT_MOC_LITERAL(1, 14, 12), \/\/ \"publishOrder\"\nQT_MOC_LITERAL(2, 27, 0), \/\/ \"\"\nQT_MOC_LITERAL(3, 28, 2), \/\/ \"id\"\nQT_MOC_LITERAL(4, 31, 5), \/\/ \"order\"\nQT_MOC_LITERAL(5, 37, 9), \/\/ \"toBuilder\"\nQT_MOC_LITERAL(6, 47, 9), \/\/ \"toDeleter\"\nQT_MOC_LITERAL(7, 57, 35), \/\/ \"on_btnTestStartDistribution_c...\"\nQT_MOC_LITERAL(8, 93, 35), \/\/ \"on_btnTestCloseDistribution_c...\"\nQT_MOC_LITERAL(9, 129, 33), \/\/ \"on_btnTestStartManagement_cli...\"\nQT_MOC_LITERAL(10, 163, 33), \/\/ \"on_btnTestCloseManagement_cli...\"\nQT_MOC_LITERAL(11, 197, 37) \/\/ \"on_btnTestFunction_singleCar1...\"\n\n    },\n    \"MasterConsole\\0publishOrder\\0\\0id\\0order\\0\"\n    \"toBuilder\\0toDeleter\\0\"\n    \"on_btnTestStartDistribution_clicked\\0\"\n    \"on_btnTestCloseDistribution_clicked\\0\"\n    \"on_btnTestStartManagement_clicked\\0\"\n    \"on_btnTestCloseManagement_clicked\\0\"\n    \"on_btnTestFunction_singleCar1_clicked\"\n};\n#undef QT_MOC_LITERAL\n\nstatic const uint qt_meta_data_MasterConsole[] = {\n\n \/\/ content:\n       8,       \/\/ revision\n       0,       \/\/ classname\n       0,    0, \/\/ classinfo\n       8,   14, \/\/ methods\n       0,    0, \/\/ properties\n       0,    0, \/\/ enums\/sets\n       0,    0, \/\/ constructors\n       0,       \/\/ flags\n       3,       \/\/ signalCount\n\n \/\/ signals: name, argc, parameters, tag, flags\n       1,    2,   54,    2, 0x06 \/* Public *\/,\n       5,    0,   59,    2, 0x06 \/* Public *\/,\n       6,    0,   60,    2, 0x06 \/* Public *\/,\n\n \/\/ slots: name, argc, parameters, tag, flags\n       7,    0,   61,    2, 0x08 \/* Private *\/,\n       8,    0,   62,    2, 0x08 \/* Private *\/,\n       9,    0,   63,    2, 0x08 \/* Private *\/,\n      10,    0,   64,    2, 0x08 \/* Private *\/,\n      11,    0,   65,    2, 0x08 \/* Private *\/,\n\n \/\/ signals: parameters\n    QMetaType::Void, QMetaType::Int, QMetaType::QString,    3,    4,\n    QMetaType::Void,\n    QMetaType::Void,\n\n \/\/ slots: parameters\n    QMetaType::Void,\n    QMetaType::Void,\n    QMetaType::Void,\n    QMetaType::Void,\n    QMetaType::Void,\n\n       0        \/\/ eod\n};\n\nvoid MasterConsole::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n    if (_c == QMetaObject::InvokeMetaMethod) {\n        auto *_t = static_cast&lt;MasterConsole *&gt;(_o);\n        Q_UNUSED(_t)\n        switch (_id) {\n        case 0: _t-&gt;publishOrder((*reinterpret_cast&lt; int(*)&gt;(_a[1])),(*reinterpret_cast&lt; QString(*)&gt;(_a[2]))); break;\n        case 1: _t-&gt;toBuilder(); break;\n        case 2: _t-&gt;toDeleter(); break;\n        case 3: _t-&gt;on_btnTestStartDistribution_clicked(); break;\n        case 4: _t-&gt;on_btnTestCloseDistribution_clicked(); break;\n        case 5: _t-&gt;on_btnTestStartManagement_clicked(); break;\n        case 6: _t-&gt;on_btnTestCloseManagement_clicked(); break;\n        case 7: _t-&gt;on_btnTestFunction_singleCar1_clicked(); break;\n        default: ;\n        }\n    } else if (_c == QMetaObject::IndexOfMethod) {\n        int *result = reinterpret_cast&lt;int *&gt;(_a[0]);\n        {\n            using _t = void (MasterConsole::*)(int , QString );\n            if (*reinterpret_cast&lt;_t *&gt;(_a[1]) == static_cast&lt;_t&gt;(&amp;MasterConsole::publishOrder)) {\n                *result = 0;\n                return;\n            }\n        }\n        {\n            using _t = void (MasterConsole::*)();\n            if (*reinterpret_cast&lt;_t *&gt;(_a[1]) == static_cast&lt;_t&gt;(&amp;MasterConsole::toBuilder)) {\n                *result = 1;\n                return;\n            }\n        }\n        {\n            using _t = void (MasterConsole::*)();\n            if (*reinterpret_cast&lt;_t *&gt;(_a[1]) == static_cast&lt;_t&gt;(&amp;MasterConsole::toDeleter)) {\n                *result = 2;\n                return;\n            }\n        }\n    }\n}\n\nQT_INIT_METAOBJECT const QMetaObject MasterConsole::staticMetaObject = { {\n    &amp;QMainWindow::staticMetaObject,\n    qt_meta_stringdata_MasterConsole.data,\n    qt_meta_data_MasterConsole,\n    qt_static_metacall,\n    nullptr,\n    nullptr\n} };\n\nconst QMetaObject *MasterConsole::metaObject() const\n{\n    return QObject::d_ptr-&gt;metaObject ? QObject::d_ptr-&gt;dynamicMetaObject() : &amp;staticMetaObject;\n}\n\nvoid *MasterConsole::qt_metacast(const char *_clname)\n{\n    if (!_clname) return nullptr;\n    if (!strcmp(_clname, qt_meta_stringdata_MasterConsole.stringdata0))\n        return static_cast&lt;void*&gt;(this);\n    return QMainWindow::qt_metacast(_clname);\n}\n\nint MasterConsole::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n{\n    _id = QMainWindow::qt_metacall(_c, _id, _a);\n    if (_id &lt; 0)\n        return _id;\n    if (_c == QMetaObject::InvokeMetaMethod) {\n        if (_id &lt; 8)\n            qt_static_metacall(this, _c, _id, _a);\n        _id -= 8;\n    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n        if (_id &lt; 8)\n            *reinterpret_cast&lt;int*&gt;(_a[0]) = -1;\n        _id -= 8;\n    }\n    return _id;\n}\n\n\/\/ SIGNAL 0\nvoid MasterConsole::publishOrder(int _t1, QString _t2)\n{\n    void *_a[] = { nullptr, const_cast&lt;void*&gt;(reinterpret_cast&lt;const void*&gt;(&amp;_t1)), const_cast&lt;void*&gt;(reinterpret_cast&lt;const void*&gt;(&amp;_t2)) };\n    QMetaObject::activate(this, &amp;staticMetaObject, 0, _a);\n}\n\n\/\/ SIGNAL 1\nvoid MasterConsole::toBuilder()\n{\n    QMetaObject::activate(this, &amp;staticMetaObject, 1, nullptr);\n}\n\n\/\/ SIGNAL 2\nvoid MasterConsole::toDeleter()\n{\n    QMetaObject::activate(this, &amp;staticMetaObject, 2, nullptr);\n}\nQT_WARNING_POP\nQT_END_MOC_NAMESPACE\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>QT\u5143\u5bf9\u8c61\u7cfb\u7edf QT\u5143\u5bf9\u8c61\u7cfb\u7edf\u7684\u4e09\u4e2a\u91cd\u8981\u7ec4\u6210\u5305\u62ec\uff1a 1\uff09QObject\u7c7b\uff08\u6240\u6709\u4f7f\u7528\u5143\u5bf9\u8c61\u7cfb\u7edf\u7684\u57fa\u7c7b\uff09 2\uff09Q_OBJECT\uff08\u6240\u5728\u7c7b\u53ef\u4ee5\u4f7f\u7528\u5143\u5bf9\u8c61\u7279\u6027\uff09 3\uff09MOC\uff08meta-object-compiler\uff0c\u5143\u5bf9\u8c61\u7f16\u8bd1\u5668\uff0c\u9884\u5904\u7406\u5305\u542bQ_OBJECT\u5b8f\u7684\u7c7b\uff09 \u6574\u4f53\u7684\u7f16\u8bd1\u8fc7\u7a0b \u9996\u5148\u8fdb\u884cMOC\u9884\u5904\u7406\uff0cQ_OBJECT\u5b8f\u5c06\u5c55\u5f00\u548c\u81ea\u52a8\u751f\u6210\u4e00\u4e9b\u53d8\u91cf\u5b9a\u4e49\u3001\u51fd\u6570\u58f0\u660e\u7b49\u4ee3\u7801\uff0c\u540c\u65f6\u751f\u6210moc_xxx.cpp\uff0c\u4e4b\u540e\u8fdb\u884c\u666e\u901a\u7f16\u8bd1\u3002 \u4fe1\u53f7\u4e0e\u69fd\u7684\u9884\u5904\u7406\uff1a\u770b\u6210\u666e\u901a\u51fd\u6570 1\uff09\u5728MOC\u9884\u5904\u7406\u8fc7\u7a0b\u4e2d\uff0cQ_OBJECT\u5c06\u5c55\u5f00\uff0c\u7c7b\u4e2d\u5b9a\u4e49\u7684\u4fe1\u53f7\u548c\u69fd\u4e5f\u88ab\u5904\u7406\u3002 2\uff09\u5904\u7406\u540e\u4f1a\u5c06\u4fe1\u53f7\u4e0e\u69fd\u90fd\u4f5c\u4e3a\u53ef\u56de\u8c03\u7684\u51fd\u6570\uff0c\u6839\u636eid\u8c03\u7528\uff0c\u51fd\u6570\u53ca\u5176id\u7684\u5b9a\u4e49\u5728Q_OBJECT\u5c55\u5f00\u7684\u51fd\u6570qt_static_metacall\u4e2d\uff0c\u5982\u5b9e\u4f8b1 3\uff09\u5176\u533a\u522b\u662f\u5728\u4e0d\u540c\u7684\u5173\u952e\u5b57\uff08signals\uff0cslots\uff09\u58f0\u660e\u4e0b\uff0c\u4fe1\u53f7\u7684\u5b9e\u73b0\u7531moc\u5b8c\u6210\uff0c\u5982\u5b9e\u4f8b2\uff0c\u800c\u69fd\u51fd\u6570\u7684\u5b9e\u73b0\u9700\u8981\u81ea\u5df1\u5b8c\u6210\u3002 \u4fe1\u53f7\u4e0e\u69fd\u7684\u5173\u8054\uff1a\u6784\u5efaConnection\u5bf9\u8c61 1\uff09connect\u51fd\u6570\u6784\u9020\u4e86\u4e00\u4e2aConnection\u5bf9\u8c61\uff0c\u5c06\u63a5\u53d1\u5bf9\u8c61\u3001\u51fd\u6570\uff08\u4fe1\u53f7\u69fd\uff09\u7684id\u3001\u8fde\u63a5\u65b9\u5f0f\u7b49\u4fdd\u5b58\u5728\u53d1\u9001\u8005\u5185\u5b58\uff0c\u5982\u5b9e\u4f8b3\u3002 2\uff09\u800c\u53d1\u9001\u8005\u5c06\u5185\u5b58\u4e2d\u7684Connection\u5bf9\u8c61\u4fdd\u5b58\u5728QObjectConnectionListVector\u4e2d\uff0cQObjectConnectionListVector\u662f\u4e2a\u6570\u7ec4\uff0c\u901a\u8fc7\u4fe1\u53f7id\u7d22\u5f15\u3002 3\uff09\u4e00\u4e2a\u4fe1\u53f7\u53ef\u4ee5\u8fde\u63a5\u591a\u4e2a\u69fd\uff0c\u5219\u4fe1\u53f7id\u7d22\u5f15\u7684\u5185\u5bb9\u662f\u6570\u7ec4\u67d0\u4e2a\u4f4d\u7f6e\u7684ConnectionList\u3002 \u4fe1\u53f7\u7684\u89e6\u53d1\u4e0e\u69fd\u7684\u6267\u884c\uff1a\u6267\u884c\u51fd\u6570\u56de\u8c03 1\uff09\u6267\u884cemit\uff0c\u5219\u76f8\u5f53\u4e8e\u8c03\u7528QMetaObject::activate\u51fd\u6570\uff0c\u6b64\u65f6\u901a\u8fc7\u4fe1\u53f7id\uff0c\u83b7\u5f97ConnectionList\u3002 2\uff09\u5bf9\u4e8e\u76f4\u8fde\u7684\u4fe1\u53f7\u69fd\uff0c\u4f1a\u76f4\u63a5\u6267\u884c\u69fd\u51fd\u6570id\u5bf9\u5e94\u7684\u51fd\u6570\uff1b 3\uff09\u5bf9\u4e8e\u961f\u5217\u8fde\u63a5\u7684\u69fd\u51fd\u6570\uff0c\u5c06\u901a\u8fc7QMetaObject::queued_activate\uff0c\u629b\u51faQMetaCallEvent\u4e8b\u4ef6\uff0c\u628aConnection\u6254\u5230\u63a5\u53d7\u8005\u6240\u5728\u7ebf\u7a0b\uff0c\u5728\u63a5\u53d7\u8005\u6240\u5728\u7ebf\u7a0b\u7684\u4e8b\u4ef6\u5faa\u73af\u4e2d\u6267\u884c\uff0c\u5982\u5b9e\u4f8b4\u3002 \u53c2\u8003 1\u3001https:\/\/www.cnblogs.com\/swarmbees\/p\/10816139.html \u5b9e\u4f8b \u5b9e\u4f8b1 void MasterConsole::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { auto *_t = static_cast&lt;MasterConsole *&gt;(_o); Q_UNUSED(_t) switch (_id) { case 0: _t-&gt;publishOrder((*reinterpret_cast&lt; int(*)&gt;(_a[1])),(*reinterpret_cast&lt; QString(*)&gt;(_a[2]))); break; case 1: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts\/212"}],"collection":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":1,"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":213,"href":"http:\/\/47.103.123.166\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions\/213"}],"wp:attachment":[{"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/47.103.123.166\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}