<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ## 概述 1. 繼承 QThread 類重寫了 run() 函數 2. 執行完成后發出一個完成信號 3. connect 處理 QThread::finished() 信號觸發 QThread::deleteLater() ``` connect(thread, &WorkerThread::finished, thread, &WorkerThread::deleteLater); ``` 4. 通過從run()函數直接或者間接地調用 QThread::exec(),可以讓線程進入事件循環 ``` while (true) { //...code exec(); } ``` ## 示例 ``` class WorkerThread : public QThread { Q_OBJECT public: WorkerThread(QObject *parent = 0) : QThread(parent) { } protected: void run() { for (int i = 0; i < 1000000000; i++); emit done(); } signals: void done(); }; // main.cpp ... // 在GUI 中顯示計時器 QTimer *timer = new QTimer(this); connect(timer, &QTimer::timeout, [=]() { static int sec = 0; lcdNumber->display(QString::number(sec++)); }); WorkerThread *thread = new WorkerThread(this); // 子線程處理完發出信號 connect(thread, &WorkerThread::done, timer, &QTimer::stop); // 子線程完成后,刪除子線程 connect(thread, &WorkerThread::finished, thread, &WorkerThread::deleteLater); // 點擊事件觸發信號 connect(button, &QPushButton::clicked, [=]() { timer->start(1); thread->start(); }); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看