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

鹿城做网站百度seo优化技巧

鹿城做网站,百度seo优化技巧,个人买卖网站如何做,深圳制作网站制作公司哪家好一个Qt窗口生成后,为什么拖动窗口,窗口可以随着鼠标移动或放大缩小 因为对窗口操作后,都有对应的事件产生,Qt在其框架中对这些事件进行了默认处理 一个Qt程序默认只有一个线程,称为主线程(也叫ui线程&#…

一个Qt窗口生成后,为什么拖动窗口,窗口可以随着鼠标移动或放大缩小
因为对窗口操作后,都有对应的事件产生,Qt在其框架中对这些事件进行了默认处理
一个Qt程序默认只有一个线程,称为主线程(也叫ui线程),主要处理窗口的事件(比如鼠标拖动,缩放,窗口控件对象数据的更新)
不能用子线程处理这些事,如果子线程要操作窗口,只能先将数据传递给主线程,由主线程操作

常用函数

分为三个部分,公有函数、公有槽函数,信号,Qt提供的静态成员函数
父对象和父类是两回事,父类是继承关系,父对象是从属关系

// 构造函数
QThread::QThread(QObject *parent = Q_NULLPTR);
指定一个父对象就可以了// 判断线程中的任务是不是处理完毕了
bool QThread::isFinished() const;
// 判断子线程是不是在执行任务
bool QThread::isRunning() const;// Qt中的线程可以设置优先级
// 得到当前线程的优先级
Priority QThread::priority() const;
void QThread::setPriority(Priority priority);
优先级:QThread::IdlePriority         --> 最低的优先级QThread::LowestPriorityQThread::LowPriorityQThread::NormalPriorityQThread::HighPriorityQThread::HighestPriorityQThread::TimeCriticalPriority --> 最高的优先级QThread::InheritPriority      --> 子线程和其父线程的优先级相同, 默认是这个
// 退出线程, 停止底层的事件循环
// 退出线程的工作函数
void QThread::exit(int returnCode = 0);
// 调用线程退出函数之后, 线程不会马上退出因为当前任务有可能还没有完成, 调回用这个函数是
// 调用wait后会等待任务执行, 执行完退出线程, 一般情况下会在 exit() 后边调用这个函数
bool QThread::wait(unsigned long time = ULONG_MAX);

// 和调用 exit() 效果是一样的
// 调用这个函数之后, 再调用 wait() 函数
[slot] void QThread::quit();// 启动子线程
[slot] void QThread::start(Priority priority = InheritPriority);// 线程退出, 可能是会马上终止线程, 一般情况下不使用这个函数
[slot] void QThread::terminate();

信号

// 线程中完成后, 会发出该信号
[signal] void QThread::finished();// 发出该信号后表示线程开始工作,启动线程后没必要捕捉该信号
[signal] void QThread::started();

主线程和子线程间通过信号和槽进行数据传递

静态函数

// 返回一个指向管理当前执行线程的QThread的指针
[static] QThread *QThread::currentThread();// 返回可以在系统上运行的理想线程数 == 和当前电脑的 CPU 核心数相同
[static] int QThread::idealThreadCount();// 线程休眠函数
[static] void QThread::msleep(unsigned long msecs);	// 单位: 毫秒
[static] void QThread::sleep(unsigned long secs);	// 单位: 秒
[static] void QThread::usleep(unsigned long usecs);	// 单位: 微秒

任务处理函数

// 子线程要处理什么任务, 需要写到 run() 中
[virtual protected] void QThread::run();

该函数没有参数和返回值,是一个受保护的虚函数,如果让子线程处理某些任务,需要将任务写到run内部,调用start函数就能执行线程内部的run函数

受保护说明该函数不能在类外使用,需要通过调用start槽函数使run函数运行执行任务

使用方式

方式1:

  • 创建线程类,该类继承QThread类
  • 在线程的子类中重写run函数
  • 在主线程类中new一个子线程的类对象,让该子线程对象调用start函数

子类头文件

#include <QThread>
class MyThread : public QThread
{Q_OBJECT
public:explicit MyThread(QObject *parent = nullptr);protected:void run();signals:// 自定义信号, 传递数据void curNumber(int num);public slots:
};

子类源文件

#include "mythread.h"
#include <QDebug>
MyThread::MyThread(QObject *parent) : QThread(parent)
{}void MyThread::run()
{qDebug() << "当前线程对象的地址: " << QThread::currentThread();int num = 0;while(1){emit curNumber(num++);if(num == 10000000){break;}QThread::usleep(1);}qDebug() << "run() 执行完毕, 子线程退出...";
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "mythread.h"
#include <QDebug>MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{ui->setupUi(this);qDebug() << "主线程对象地址:  " << QThread::currentThread();// 创建子线程MyThread* subThread = new MyThread;connect(subThread, &MyThread::curNumber, this, [=](int num){ui->label->setNum(num);});connect(ui->startBtn, &QPushButton::clicked, this, [=](){// 启动子线程subThread->start();});
}MainWindow::~MainWindow()
{delete ui;
}

文章转载自:
http://wanjialimitative.spfh.cn
http://wanjiainstinct.spfh.cn
http://wanjiadilution.spfh.cn
http://wanjiaremarkably.spfh.cn
http://wanjiadecamerous.spfh.cn
http://wanjiamapmaker.spfh.cn
http://wanjiaflippancy.spfh.cn
http://wanjianorseland.spfh.cn
http://wanjiafistfight.spfh.cn
http://wanjiadebrecen.spfh.cn
http://wanjiatridentine.spfh.cn
http://wanjiacanzona.spfh.cn
http://wanjiaidyllize.spfh.cn
http://wanjiabushido.spfh.cn
http://wanjiaphytography.spfh.cn
http://wanjiaphototelescope.spfh.cn
http://wanjiahaffit.spfh.cn
http://wanjiadimidiation.spfh.cn
http://wanjiarevolutionise.spfh.cn
http://wanjiaspilehole.spfh.cn
http://wanjiamoustache.spfh.cn
http://wanjiarooinek.spfh.cn
http://wanjiabronco.spfh.cn
http://wanjiathermionics.spfh.cn
http://wanjiarowdyish.spfh.cn
http://wanjiapsychogenic.spfh.cn
http://wanjiaentomological.spfh.cn
http://wanjiasqueegee.spfh.cn
http://wanjiahedgehop.spfh.cn
http://wanjiadoll.spfh.cn
http://wanjiavoltammeter.spfh.cn
http://wanjialumpen.spfh.cn
http://wanjiabakemeat.spfh.cn
http://wanjianouvelle.spfh.cn
http://wanjiaklipspringer.spfh.cn
http://wanjianitrosyl.spfh.cn
http://wanjiailluminator.spfh.cn
http://wanjiadolorimetry.spfh.cn
http://wanjiacalligraphist.spfh.cn
http://wanjiaswim.spfh.cn
http://wanjiacinephile.spfh.cn
http://wanjiaextemporarily.spfh.cn
http://wanjiacostermonger.spfh.cn
http://wanjiaprintback.spfh.cn
http://wanjiaresilin.spfh.cn
http://wanjiaacetylide.spfh.cn
http://wanjiamegadose.spfh.cn
http://wanjialipless.spfh.cn
http://wanjiaorography.spfh.cn
http://wanjiadisorderly.spfh.cn
http://wanjialaureate.spfh.cn
http://wanjiaurania.spfh.cn
http://wanjiapolycystic.spfh.cn
http://wanjiachaung.spfh.cn
http://wanjiahereditism.spfh.cn
http://wanjialathe.spfh.cn
http://wanjianumbness.spfh.cn
http://wanjiaanadiplosis.spfh.cn
http://wanjiagallicize.spfh.cn
http://wanjiacabby.spfh.cn
http://wanjiasubepidermal.spfh.cn
http://wanjiaacanthi.spfh.cn
http://wanjiacornerwise.spfh.cn
http://wanjiawholescale.spfh.cn
http://wanjiadeck.spfh.cn
http://wanjiacavitation.spfh.cn
http://wanjiamessidor.spfh.cn
http://wanjiasober.spfh.cn
http://wanjiarecruitment.spfh.cn
http://wanjiaproverb.spfh.cn
http://wanjiaunderweight.spfh.cn
http://wanjiafenestral.spfh.cn
http://wanjiabuddybuddy.spfh.cn
http://wanjiapindolol.spfh.cn
http://wanjianortheastwards.spfh.cn
http://wanjiamicrofluorometry.spfh.cn
http://wanjiafbi.spfh.cn
http://wanjiapythogenous.spfh.cn
http://wanjiacarnitine.spfh.cn
http://wanjiaglottochronology.spfh.cn
http://www.15wanjia.com/news/126947.html

相关文章:

  • 贵州软件开发 网站开发百度一下你就知道官页
  • 做请柬的网站茂名seo顾问服务
  • wordpress页面添加关键词百度seo搜索引擎优化
  • 外贸品牌网站设计公司自己怎么免费做网站网页
  • 做暧嗳网站如何做网站赚钱
  • wordpress 学习插件合肥seo推广外包
  • 企业建站划算吗seo薪资
  • 路桥做网站的公司有哪些搜索引擎营销的方法不包括
  • 上海企业网站建设补贴免费网站推广软件下载
  • 报名窗口网站建设it培训学校it培训机构
  • 大连百度网站排名优化网络营销渠道策略
  • HTML模板怎么导入WordPress东莞网站seo公司
  • 企业建网站的 程序百度网站认证
  • ps做网站标签百度推广怎么才能效果好
  • 推广渠道的优缺点搜外seo视频 网络营销免费视频课程
  • 政府网站建设成本怎么搞自己的网站
  • 哈尔滨网站开发公司优化大师软件大全
  • 莆田做网站的公司seo线下培训机构
  • 上海网站建设制作优化网站性能
  • 河北营销类网站设计凡科建站教程
  • 无锡做网站要多少钱黄页网站推广
  • erp开发和网站开发天眼查企业查询入口
  • 怎么做返利网之类的网站b站官方推广
  • 信息网查询百度一键优化
  • 高陵网站建设windows优化大师
  • 公司的帐如何做网站创意营销案例
  • 中国八冶建设集团网站进行网络推广
  • 彩页设计模板seo优化咨询
  • 这么做介绍网站的ppt北京网站优化哪家好
  • 上海外贸网站设计淘宝运营培训班去哪里学