博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
QT moveToThread 实现多线程记录
阅读量:4126 次
发布时间:2019-05-25

本文共 384 字,大约阅读时间需要 1 分钟。

前提: 自己曾经用过n多次,但是时间总是这么不经意间带走了我清晰的记忆。所以在此记录一下

 

1. 需要放到线程中 处理的类(继承于 QObject)

2. QThread 类对象

3. 处理的类 调用 moveToThrad(QThteadl 类对象)

4. QThread 类对象 调用 star() 方法

 

例子:

//头文件声明WebSocketServer *mWebServer;QThread mWebServerThread;// cpp 文件实现 mWebServer = new WebSocketServer(NULL); mWebServer->moveToThread(&mWebServerThread); //----------可以添加 connect 一些槽的操作 ---------// mWebServerThread.start();

 

转载地址:http://xarpi.baihongyu.com/

你可能感兴趣的文章
OKhttp之Call接口
查看>>
application/x-www-form-urlencoded、multipart/form-data、text/plain
查看>>
关于Content-Length
查看>>
WebRequest post读取源码
查看>>
使用TcpClient可避免HttpWebRequest的常见错误
查看>>
EntityFramework 学习之一 —— 模型概述与环境搭建 .
查看>>
C# 发HTTP请求
查看>>
启动 LocalDB 和连接到 LocalDB
查看>>
Palindrome Number --回文整数
查看>>
Reverse Integer--反转整数
查看>>
Container With Most Water --装最多水的容器(重)
查看>>
Longest Common Prefix -最长公共前缀
查看>>
Letter Combinations of a Phone Number
查看>>
Single Number II --出现一次的数(重)
查看>>
Valid Parentheses --括号匹配
查看>>
Remove Element--原地移除重复元素
查看>>
Remove Duplicates from Sorted Array--从有序数组中移除重复元素
查看>>
Count and Say
查看>>
Palindrome Partitioning --回文切割 深搜(重重)
查看>>
Valid Palindrome 简单的回文判断
查看>>