Qt QThread多线程模版
2017-01-23 10:07
309 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/d821040387/article/details/54691571
WorkerThread.h头文件
#ifndef WORKERTHREAD_H #define WORKERTHREAD_H #include <QThread> #include <QDebug> class WorkerThread : public QThread { Q_OBJECT public: WorkerThread(QObject* parent = NULL); ~WorkerThread(); void startThread(); void quitThread(); void run(); protected: bool bQuitThread; }; #endif // THREAD_HWorkerThread.cpp源文件
#include "WorkerThread.h" WorkerThread::WorkerThread(QObject* parent):QThread(parent),bQuitThread(false) { } WorkerThread::~WorkerThread() { quitThread(); } void WorkerThread::startThread() { if(!this->isRunning()){ bQuitThread = false; this->start(); } } void WorkerThread::quitThread() { if(isRunning()){ bQuitThread = true; this->wait(); } } void WorkerThread::run() { while (!bQuitThread) { qDebug() << "ThreadId =" <<currentThreadId(); msleep(50); } }
相关文章推荐
- isap 最大流 模版
- KM匹配 hdu2853(模版
- silverlight/wpf 通过后台创建datagrid模版列
- 无比强大!Python抓取cssmoban站点的模版并下载
- 02 设计模式之--模版设计模式
- 卷积运算中5X5卷积模版的实现-verilog
- django的模版中访问数组
- HDU 2069 母函数模版题
- 修改PPT的模版
- IAR for ARM 工程模版不兼容修改方法
- thinkphp tp 中做编辑模版的功能
- 最近点对模版
- 计算机网络专业 简历 模版
- HDU 3068 最长回文 【manacher模版】
- 【WindowsPhone】--(二)主题、样式与模版
- doT.js html模版使用教程
- smarty模版
- ACM模版-f_zyj v 2.0——更新通知
- dijkstra O(n2) 算法模版
- 数学建模--人工鱼群算法的模版