当前位置: 首页 > news >正文

天津电商网站开发备案查询站长之家

天津电商网站开发,备案查询站长之家,高密哪里做网站,做网站的图片用什么格式功能: qt中用多线程的方式调用python脚本,完成C++和python之间的数据交互。为了满足多任务并发的要求,将调用python的逻辑部分封装到QThread的子类PyApiThread中。 主要实现: 包括PyApiThread的实现以及在主线程中如何使用 PyApiThread的的实现,分.h和.cpp两个文件 #ifnd…功能: qt中用多线程的方式调用python脚本,完成C++和python之间的数据交互。为了满足多任务并发的要求,将调用python的逻辑部分封装到QThread的子类PyApiThread中。 主要实现: 包括PyApiThread的实现以及在主线程中如何使用 PyApiThread的的实现,分.h和.cpp两个文件 #ifndef PYAPITHREAD_H #define PYAPITHREAD_H#include "Python.h" #include QMap #include QQueue #include QThread #include QVariantclass QMutex; class Widget; class QEventLoop; class PyApiThread : public QThread {Q_OBJECT public: explicit PyApiThread(Widget* parent = nullptr);~PyApiThread();bool isRunning()const;void setSleepTime(uint ms); Q_INVOKABLE void stopRuning(); Q_INVOKABLE void stopPyApi(const QString pyfile);void addPyApi(const QString pyfile, const QString function,const QStringList paramters, const QVariant attachInfo=""); signals:void stopThreadWork();void startPyApiTask(const QString api);void finishPyApiTask(const QString api, bool cancel);void pyCommandResult(const QVariant result);protected:void run();private:QVariant getPyCmd();QVariant getPyCmdResult();void addPyApiResult(const QVariant result);bool cancelPyApi();void sleepThread(uint ms); void initPythonEnviroement();QVariant parsePyObj(PyObject* obj);QVariant parsePyList(PyObject* obj);QVariant parsePyTuple(PyObject* obj);QVariant parsePyDictionary(PyObject* obj);QVariant parsePySimpleObj(PyObject* obj);const char* printPyApiError(const QString prefix);QVariant executePyScript(const QString pyfile, const QString function,const QStringList paramters, const QVariant attachInfo);bool needExecuteExterProcess(const QString pyfile, const QStringList paramters, QVariantMap result);int executeExterProcess(const QString pyfile, const QStringList paramters);private:uint mSleepTime = 80;bool mRunning = false;//bool mPlatformInit = true;QQueueQVariant mApiQueue; //后面改成无锁队列 QQueueQString mSystemQueue; //后面改成无锁队列QQueueQVariant mApiQueueResult; //后面改成无锁队列QMutex* mMutex = nullptr; QMutex* mSysMutex = nullptr;QEventLoop* mEventLoop = nullptr;Widget* mParent{nullptr};//QMapQString, QVariant(PyApiThread::*)(const QVariantMap) mFuncs; };#endif // PYAPITHREAD_H#include "pyapithread.h" //#include "pyinterface.h" #include "rlog.h" #include "widget.h"#include QDebug #include QMutex #include QTimer #include QWidget #include QDateTime #include QEventLoop #include QtConcurrent #include QCoreApplicationclass PythonThreadLocker {PyGILState_STATE state; public:PythonThreadLocker() : state(PyGILState_Ensure()){}~PythonThreadLocker() {PyGILState_Release(state);} };PyApiThread::PyApiThread(Widget *parent):mParent(parent) { }PyApiThread::~PyApiThread() {if(mMutex){delete mMutex;mMutex = nullptr;}if(mSysMutex){delete mSysMutex;mSysMutex = nullptr;}if(mEventLoop){mEventLoop-quit();delete mEventLoop;mEventLoop = nullptr;}}void PyApiThread::stopRuning() { mRunning = false;mEventLoop-quit();emit stopThreadWork();qDebug()"stopRuning
http://www.pierceye.com/news/569129/

相关文章:

  • 建网站哪家好案例网页设计感悟与体会
  • 做网站要实名吗深圳货拉拉
  • 综合门户网站是什么意思建设机械网站
  • 主题资源网站建设作业高级网站开发工程师考试题
  • 含山建设局网站免费的个人简历模板文档
  • 门户网站建设推荐高校英文网站建设 文献综述
  • 织梦网站备案免费咨询网站
  • wordpress站内搜索插件网站管理程序
  • 网站建设友链交换自己电脑做网站iis
  • 全球优秀企业网站做原型的素材网站
  • 单页面营销网站怎么用polylang做网站
  • 网站开发入那个科目中国网站建设哪家公司好
  • 网站流量提升方案软件公司名称大全查询
  • 怎么做淘客专属网站济南公司网站推广优化最大的
  • 苏州网站建设极简幕枫织梦模板网站源码
  • 青岛网站设计定制2023传奇手游排行榜
  • 商务酒店网站建设淮南网备案查询
  • 菏泽炫佑网站建设中国城乡建设部网站
  • 网站开发与移动互联自助建站的优点与缺点
  • 公司做网站的好处上海网站设计找哪家
  • 个人如果做网站赚钱吗WordPress 聊天小工具
  • 商城网站建设哪家便宜网络架构师和网络工程师区别
  • p2p网站建设 深圳广东手机网站建设品牌
  • 亚马逊网上商城是正品吗长沙seo计费管理
  • 东莞品牌网站建设多少钱网站设计有限公司怎么样
  • dedecms新网站 上传到万网的空间浦口区网站建站公司
  • 龙岗在线网站建设西安房产信息网
  • 如何建立公司企业网站大朗做网站的
  • 怎么做整蛊网站wordpress系统的特点
  • php网站开发视频教程浙江建设局网站