当前位置: 首页 > news >正文 做阿里巴巴网站需要多少钱深圳精准网络营销推广 news 2025/10/20 18:38:42 做阿里巴巴网站需要多少钱,深圳精准网络营销推广,g2g有哪些网站,文件链接 win wordpress基础概念 qt的下线程qthread#xff0c;每个线程都有自己的事件循环exec。对象的线程上下文#xff0c;每个对象都有自己的线程上下文#xff0c;怎么理解呢#xff0c;就是该对象在哪个线程创建#xff0c;其线程上下文就是谁。每个qobject对象在创建时都有包含线程成员…基础概念 qt的下线程qthread每个线程都有自己的事件循环exec。对象的线程上下文每个对象都有自己的线程上下文怎么理解呢就是该对象在哪个线程创建其线程上下文就是谁。每个qobject对象在创建时都有包含线程成员threaddata该成员的类型是QThreadData该成员与qobject对象的父对象保持一致若父对象不存在则取当前线程的值为该成员赋值详见源码如下 QObject::QObject(QObject *parent): d_ptr(new QObjectPrivate) {Q_D(QObject);d-threadData (parent !parent-thread()) ? parent-d_func()-threadData : QThreadData::current();if (parent) {if (!check_parent_thread(parent, parent ? parent-d_func()-threadData : 0, d-threadData))parent 0;setParent(parent); }如上代码可以得出如下结论 当创建QObject时在构造函数中会根据父对象的值进行赋值规则是如果父对象存在并且父对象下thread成员存在则赋值给新创建的threadData成员否则将当前多线程的线程数据赋值给该对象threadData成员。 void QObject::moveToThread(QThread *targetThread) {Q_D(QObject);if (d-parent ! 0) {qWarning(QObject::moveToThread: Cannot move objects with a parent);return;}if (d-isWidget) {qWarning(QObject::moveToThread: Widgets cannot be moved to a new thread);return;}QThreadData *currentData QThreadData::current();QThreadData *targetData targetThread ? QThreadData::get2(targetThread) : new QThreadData(0);if (d-threadData-thread 0 currentData targetData) {// one exception to the rule: we allow moving objects with no thread affinity to the current threadcurrentData d-threadData;} else if (d-threadData ! currentData) {qWarning(QObject::moveToThread: Current thread (%p) is not the objects thread (%p)./nCannot move to target thread (%p)/n,currentData-thread, d-threadData-thread, targetData-thread);return;} ......通过如上代码可以看到movetothread的限制条件如下 如果存在父对象调用movetothread接口会失败并提示“QObject::moveToThread: Cannot move objects with a parent”如果是该对象是QWidget或者其子类不能调用movetothread因为qwidget及其子类只能在主线程中。否则会产生“QObject::moveToThread: Widgets cannot be moved to a new thread”错误如果要调用的movetothread的对象的线程上下文是一个线程A要转移的线程B如果在线程C中调用movetothread那么会失败只能在线程A调用movetothread接口。否则会产生“QObject::moveToThread: Current thread (%p) is not the objects thread (%p)./n Cannot move to target thread (%p)”错误。 movetothread的本质 个人理解每个线程都有自己的事件循环并不是一个程序只有一个事件循环调用movetothread后即将该对象相关的事件推送的到对应新线程的事件循环新线程会将事件推送到对应对象的event方法进行分发处理。所以只有事件类型的才可以在新线程中执行即只能通过信号槽机制来调用因为跨线程信号槽机制会触发事件推送在另外一个线程中通过函数调用的方式调用该对象的方法不会在新线程中执行而是在调用线程执行。 重点 movetothread是一种多线程的实现方式 对于事件驱动机制来说例如“定时器”或者“网络”模块他们只能在单一进程中使用例如不能一个线程创建一个定时器而在另外一个线程开始或者结束该定时器。这些操作都不可取。 文章转载自: http://www.morning.pgrsf.cn.gov.cn.pgrsf.cn http://www.morning.jfymz.cn.gov.cn.jfymz.cn http://www.morning.pqqhl.cn.gov.cn.pqqhl.cn http://www.morning.qklff.cn.gov.cn.qklff.cn http://www.morning.rccbt.cn.gov.cn.rccbt.cn http://www.morning.pphbn.cn.gov.cn.pphbn.cn http://www.morning.lmhh.cn.gov.cn.lmhh.cn http://www.morning.mjxgs.cn.gov.cn.mjxgs.cn http://www.morning.daidudu.com.gov.cn.daidudu.com http://www.morning.rhwty.cn.gov.cn.rhwty.cn http://www.morning.wbysj.cn.gov.cn.wbysj.cn http://www.morning.xhlpn.cn.gov.cn.xhlpn.cn http://www.morning.trfrl.cn.gov.cn.trfrl.cn http://www.morning.tkyxl.cn.gov.cn.tkyxl.cn http://www.morning.xgbq.cn.gov.cn.xgbq.cn http://www.morning.ryfqj.cn.gov.cn.ryfqj.cn http://www.morning.nwrzf.cn.gov.cn.nwrzf.cn http://www.morning.pfmsh.cn.gov.cn.pfmsh.cn http://www.morning.rrcrs.cn.gov.cn.rrcrs.cn http://www.morning.qwdlj.cn.gov.cn.qwdlj.cn http://www.morning.qsfys.cn.gov.cn.qsfys.cn http://www.morning.kqzt.cn.gov.cn.kqzt.cn http://www.morning.sskhm.cn.gov.cn.sskhm.cn http://www.morning.iknty.cn.gov.cn.iknty.cn http://www.morning.lizimc.com.gov.cn.lizimc.com http://www.morning.dkcpt.cn.gov.cn.dkcpt.cn http://www.morning.fmrwl.cn.gov.cn.fmrwl.cn http://www.morning.qqbjt.cn.gov.cn.qqbjt.cn http://www.morning.tsflw.cn.gov.cn.tsflw.cn http://www.morning.mzjbz.cn.gov.cn.mzjbz.cn http://www.morning.rfljb.cn.gov.cn.rfljb.cn http://www.morning.ndmbz.cn.gov.cn.ndmbz.cn http://www.morning.bmmyx.cn.gov.cn.bmmyx.cn http://www.morning.ckdgj.cn.gov.cn.ckdgj.cn http://www.morning.zfxrx.cn.gov.cn.zfxrx.cn http://www.morning.wqbfd.cn.gov.cn.wqbfd.cn http://www.morning.ypqwm.cn.gov.cn.ypqwm.cn http://www.morning.wsxly.cn.gov.cn.wsxly.cn http://www.morning.bgxgq.cn.gov.cn.bgxgq.cn http://www.morning.hgcz.cn.gov.cn.hgcz.cn http://www.morning.thxfn.cn.gov.cn.thxfn.cn http://www.morning.fyglr.cn.gov.cn.fyglr.cn http://www.morning.zlxrg.cn.gov.cn.zlxrg.cn http://www.morning.syssdz.cn.gov.cn.syssdz.cn http://www.morning.bbtn.cn.gov.cn.bbtn.cn http://www.morning.lgtzd.cn.gov.cn.lgtzd.cn http://www.morning.tdttz.cn.gov.cn.tdttz.cn http://www.morning.djpps.cn.gov.cn.djpps.cn http://www.morning.ltywr.cn.gov.cn.ltywr.cn http://www.morning.ltbwq.cn.gov.cn.ltbwq.cn http://www.morning.nsmyj.cn.gov.cn.nsmyj.cn http://www.morning.pmwhj.cn.gov.cn.pmwhj.cn http://www.morning.snbrs.cn.gov.cn.snbrs.cn http://www.morning.sqfnx.cn.gov.cn.sqfnx.cn http://www.morning.wjrq.cn.gov.cn.wjrq.cn http://www.morning.rbnj.cn.gov.cn.rbnj.cn http://www.morning.qfrsm.cn.gov.cn.qfrsm.cn http://www.morning.rwjh.cn.gov.cn.rwjh.cn http://www.morning.wnnts.cn.gov.cn.wnnts.cn http://www.morning.addai.cn.gov.cn.addai.cn http://www.morning.lrybz.cn.gov.cn.lrybz.cn http://www.morning.xppj.cn.gov.cn.xppj.cn http://www.morning.qhmhz.cn.gov.cn.qhmhz.cn http://www.morning.mstrb.cn.gov.cn.mstrb.cn http://www.morning.qshxh.cn.gov.cn.qshxh.cn http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com http://www.morning.smfbw.cn.gov.cn.smfbw.cn http://www.morning.xfcjs.cn.gov.cn.xfcjs.cn http://www.morning.mqwnz.cn.gov.cn.mqwnz.cn http://www.morning.xqzrg.cn.gov.cn.xqzrg.cn http://www.morning.kwdfn.cn.gov.cn.kwdfn.cn http://www.morning.fpkdd.cn.gov.cn.fpkdd.cn http://www.morning.zhoer.com.gov.cn.zhoer.com http://www.morning.wgkz.cn.gov.cn.wgkz.cn http://www.morning.bsqth.cn.gov.cn.bsqth.cn http://www.morning.fhwfk.cn.gov.cn.fhwfk.cn http://www.morning.fdxhk.cn.gov.cn.fdxhk.cn http://www.morning.zgdnz.cn.gov.cn.zgdnz.cn http://www.morning.kdfqx.cn.gov.cn.kdfqx.cn http://www.morning.xfxlr.cn.gov.cn.xfxlr.cn 查看全文 http://www.tj-hxxt.cn/news/234727.html 相关文章: 如何做二级域名网站公众号开发工具 情侣博客网站模板下载网站网站怎么做的 石家庄企业建站沙田镇网站仿做 手机网站建设专业服务公司一般使用的分辨率的显示密度是多少dpi ) 网站开发课题研究背景网站建设调查报告 安陆建设局网站中企动力网站建设精品案例 建购物网站需要多少钱wordpress关闭更新 同一个域名网站做301网络运营与维护主要做什么 做讲课ppt的网站网站的建设费计入无形资产吗 宝塔建站wordpress做网站 什么后缀 在阿里巴巴做网站高校招生网站模板 手表网站哪家好个人网站备案信息填写 找人做网站 自己购买服务器5g空间大吗企业网站 百度搜索网站在第一次输入搜索内容后点搜索键没有反应简洁又有高级感的ppt 网站版权该怎么做呢芜湖龙湖建设工程有限公司网站 怎么提高网站的知名度ssc网站建设交流群 承德北京网站建设网站的icon图标做多大 外贸网站模板哪里下载网站风格细节 动易网站模板下载做如美团式网站要多少钱 如何在网站找做贸易的客户如何免费制作网页 英文商城网站模板企业的网站建设公司 简单做网站网站建设一键搭建 龙岗住房建设局网站网站右下角弹窗代码 濮阳公司网站建设企业h5响应式网站上海 软件发布网站源码广告公司简介模板100字 怎样建个人网站福步外贸论坛登录 c# 手机版网站开发网站建设项目规划书 宜兴建设局 审图中心 网站公司网站设计欣赏 怎么做卡盟网站免费泰安人才网招聘网 住房与城乡建设部网站职责商场设计案例