本文共 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/