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

建一个收费网站网站备案没通过不了

建一个收费网站,网站备案没通过不了,仙居网站设计,郑州企业推广QThread::CurrentThread是指的当前函数调用者者所在的线程 this-thread是指的当前对象所在的线程#xff08;对象创建出来的时候所在的线程#xff09; Qt文档说明 CurrentThread返回一个指向管理当前执行线程的QThread的指针 thread返回对象所在的线程 这两个函数所…QThread::CurrentThread是指的当前函数调用者者所在的线程 this-thread是指的当前对象所在的线程对象创建出来的时候所在的线程 Qt文档说明 CurrentThread返回一个指向管理当前执行线程的QThread的指针 thread返回对象所在的线程 这两个函数所说的并不是一回事 如果想要将一个对象保证在主线程中处理一些事情应该是使用this-thread来判断对象所处的线程而并不是使用QThread::CurrentThread来判断对象所处的线程 mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H#include QMainWindow #include mythread.hQT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACEclass MainWindow : public QMainWindow {Q_OBJECTpublic:MainWindow(QWidget *parent nullptr);~MainWindow();private slots:void on_pushButton_clicked();signals:void sigTest(); private:Ui::MainWindow *ui;MyThread *m_pThread; }; #endif // MAINWINDOW_Hmainwindow.cpp  #include mainwindow.h #include ui_mainwindow.hMainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow) {ui-setupUi(this);m_pThread new MyThread();m_pThread-start(); }MainWindow::~MainWindow() {delete ui; }void MainWindow::on_pushButton_clicked() {m_pThread-m_flag ui-checkBox-checkState(); } mythread.h #ifndef MYTHREAD_H #define MYTHREAD_H #include QThreadclass MyThread:public QThread {Q_OBJECT public:MyThread();bool m_flag false;protected:void run();};#endif // MYTHREAD_Hmythread.cpp #include mythread.h #include singleclass.h #include QDebugMyThread::MyThread() {}void MyThread::run() {qDebug()子线程QThread::currentThread();while(true){QThread::msleep(100);if(m_flag){SingleClass::getInstance()-Test();m_flag false;}} }singleclass.h 测试对象 #ifndef SINGLECLASS_H #define SINGLECLASS_H#include QObjectclass SingleClass : public QObject {Q_OBJECT public:static SingleClass* getInstance();void Test(); public slots:void slotTest(); signals:void sigTest();private:explicit SingleClass(); };#endif // SINGLECLASS_Hsingleclass.cpp #include singleclass.h #include QThread #include QDebug #include QApplicationSingleClass::SingleClass() {connect(this,SingleClass::sigTest,this,SingleClass::slotTest,Qt::BlockingQueuedConnection); }SingleClass* SingleClass::getInstance() {static SingleClass instance;return instance; }void SingleClass::Test() {qDebug()Test;qDebug()currentThread:QThread::currentThread();qDebug()this线程this-thread();if(this-thread() ! qApp-thread()){qDebug()this 所在的线程非主线程移动到主线程中;moveToThread(qApp-thread());}qDebug()after:;qDebug()currentThread__FUNCTION__QThread::currentThread();qDebug()this 线程this-thread();emit sigTest(); }void SingleClass::slotTest() {qDebug()slotTest;qDebug()信号发出者所在的线程sender()-thread();qDebug()currentThread__FUNCTION__QThread::currentThread();qDebug()this 线程this-thread(); }main.cpp #include mainwindow.h#include QApplication #include SingleClass.hint main(int argc, char *argv[]) {QApplication a(argc, argv);//如果在这里调用那么对象所处的线程直接就是主线程// SingleClass::getInstance();qDebug()主线程QThread::currentThread();MainWindow w;w.show();return a.exec(); }界面 点击按钮之后输出 主线程 QThread(0x20d70e06b00) 子线程 MyThread(0x20d70e7db40) Test currentThread: MyThread(0x20d70e7db40) this线程 MyThread(0x20d70e7db40) this 所在的线程非主线程移动到主线程中 after: currentThread SingleClass::Test MyThread(0x20d70e7db40) this 线程 QThread(0x20d70e06b00) slotTest 信号发出者所在的线程 QThread(0x20d70e06b00) currentThread SingleClass::slotTest QThread(0x20d70e06b00) this 线程 QThread(0x20d70e06b00) 可以看到SingleClass这个类对象是在子线程中的CurrentThread线程是子线程 之后调用moveToThread之后singClass类对象是移动到了主线程所以通过使用connect(this,SingleClass::sigTest,this,SingleClass::slotTest,Qt::BlockingQueuedConnection); 因为是队列连接所以槽函数是在槽函数所在的线程中执行的  之后发出信号之后slotTest就是在主线程中执行了 注意信号是在子线程中发出槽函数是在主线程执行的 信号发出的线程并不是指的信号所在的对象的线程而是发出信号时候的被调用函数的所在的线程
http://www.hkea.cn/news/14337331/

相关文章:

  • 巴南市政建设网站沈阳vi设计公司
  • h5网站制作费用我想做社区团购怎么做
  • 贵阳网站建手机网站搭建多少钱
  • 怎么做网站内容调研网页制作图片教程
  • 龙岩网站开发网站使用微信支付
  • 企业网站是怎么建站的巩义网络推广外包
  • 北京个人网站制作淮安哪里有做网站的人
  • 电子商务网站规划建设方案网络建设方式
  • 站长统计app进入网址大连网站制作-中国互联
  • 罗田企业网站建设河北省最新消息
  • 怎样做网站国外印章在线制作
  • 周易网站建设苏州正规网站建设概况
  • 做网站费用怎么付免费自动网页生成器
  • discuz网站模板下载wampserver和wordpress
  • 做网站的封面图片哪里才有做模版网站需要租服务器吗
  • 贵阳网站制作软件网站建设的思想
  • 怎样做网站怎要加服务器wordpress熊掌号资源提交
  • 企业网站建设的一般要素有哪些网站可以免费做代码
  • 内蒙能源建设集团网站如何做企业网站后台管理
  • 怎么申请做网站成都网络推广运营公司
  • 公司网站制作新手教程wordpress 自定义按钮
  • 中国铁路建设监理协会官方网站做网站代码编辑工具
  • 汕头网站外包江苏省建设厅网站建造师强制注销
  • 昆明网站制作公司百度推广网站建设公司 深圳
  • 台州网站制作开发做网站哪家比较好
  • 除了网页外 网站还需要上海自贸区注册公司优惠政策
  • 做薪酬调查的网站上海市建设执业注册中心网站
  • 列出网站开发建设的步骤株洲定制网站建设
  • 如何k掉别人的网站自助小站
  • 新农村建设管理网站如何建设网站pdf下载