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

dede网站名称更改不了seo 优化 服务

dede网站名称更改不了,seo 优化 服务,网站项目接单,图片加文字制作Qt中的异步相关类 今天在学习别人的项目时,看到别人包含了QFuture类,我没有见过,于是记录一下。 直接在AI助手中搜索QFuture,得到的时Qt中异步相关的类。于是直接查询一下Qt异步中相关的类。 在Qt中,异步编程是一个重要的概念&…

Qt中的异步相关类

今天在学习别人的项目时,看到别人包含了QFuture类,我没有见过,于是记录一下。

直接在AI助手中搜索QFuture,得到的时Qt中异步相关的类。于是直接查询一下Qt异步中相关的类。

在Qt中,异步编程是一个重要的概念,它允许开发者在不阻塞主线程的情况下执行耗时的任务。

  1. Qt Concurrent
    • 提供了并行处理迭代容器的map、filter和reduce算法,类似于函数式编程中的概念。
    • 包括QFutureQFutureWatcherQFutureSynchronizer等类,用于访问和监控异步计算的结果。
  2. QFuture
    • 表示一个异步操作的结果,可以附加继续操作(continuations)。
    • 通过QFuture::then()方法,可以在一个异步操作完成后继续执行另一个操作。
    • 支持错误处理,通过QFuture::onFailed()方法可以为特定错误类型附加错误处理程序。
  3. QFutureWatcher
    • 用于监控QFuture对象的状态,如完成、失败或取消。
    • QFuture的状态发生变化时,QFutureWatcher可以发出信号。
  4. QThreadPool
    • 用于管理线程池,可以提交任务到线程池中异步执行。
  5. Qt::runFunction
    • 一个模板函数,用于在后台线程中异步执行函数,并返回一个QFuture对象。
  6. Qt::connect
    • 可以与QFuture一起使用,将信号连接到槽上,以便在异步操作完成时执行槽函数。
  7. qt-async
    • 一个第三方库,提供了异步值(async values)和异步小部件(async widgets),用于异步操作的结果、错误和进度的表示。
  8. QtAsyncSql
    • 一个第三方库,提供了异步和线程化的SQL查询支持。
    • 包括AsyncQuery类,用于执行异步SQL查询。
    • 提供了ConnectionManager类,用于维护数据库连接。
  9. QtAsyncRunner
    • 一个抽象接口,用于启动异步函数,允许在Qt应用程序中轻松地将计算密集型函数提交到线程中执行。

1.使用QFutureQFutureWatcher进行异步操作

#include <QCoreApplication>
#include<QFuture>
#include<QFutureWatcher>
#include<QtConcurrent/QtConcurrentRun>
#include<QDebug>void AsyncTask(int nNumber)
{QThread::sleep(2); // 模拟耗时操作qDebug() << "Task Complete With Number:" << nNumber;
}int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);// 使用QtConcurrent::run将函数提交到线程池QFuture<void> future = QtConcurrent::run(AsyncTask,42);// 创建一个QFutureWatcher来监控任务QFutureWatcher<void> watcher;QObject::connect(&watcher,&QFutureWatcher<void>::finished,&a,&QCoreApplication::quit);// 将watcher与future关联watcher.setFuture(future);QtConcurrent::run(AsyncTask,42);return a.exec();
}
  1. 使用QThreadPoolQt::runFunction进行异步操作

    #include <QCoreApplication>
    #include <QThreadPool>
    #include <QtConcurrent/QtConcurrentRun>
    #include <QDebug>void myFunction() {qDebug() << "Function is running in a separate thread.";
    }int main(int argc, char *argv[]) {QCoreApplication a(argc, argv);// 将函数提交到线程池QtConcurrent::run(&myFunction);// 启动事件循环,等待异步任务完成return a.exec();
    }
    

3. 使用QFuture链式调用(Continuations)

#include <QCoreApplication>
#include <QFuture>
#include <QtConcurrent/QtConcurrentRun>
#include <QDebug>QString processResult(int number) {return QString("Processed %1").arg(number);
}int main(int argc, char *argv[]) {QCoreApplication a(argc, argv);// 异步执行任务并获取结果QFuture<int> future = QtConcurrent::run([]() -> int {QThread::sleep(2); // 模拟耗时操作return 42;});// 使用then()方法添加一个continuationQFuture<QString> processedFuture = future.then(&processResult);// 等待处理结果QString result = processedFuture.result();qDebug() << result;// 启动事件循环,等待异步任务完成return a.exec();
}

上述程序在同一程序运行结果:
在这里插入图片描述

好了,相关介绍就到这里。


文章转载自:
http://disapprovingly.mnqg.cn
http://jwv.mnqg.cn
http://astronautically.mnqg.cn
http://quantitate.mnqg.cn
http://pauper.mnqg.cn
http://overshirt.mnqg.cn
http://overtechnologize.mnqg.cn
http://columbous.mnqg.cn
http://seasoning.mnqg.cn
http://anemometric.mnqg.cn
http://sprite.mnqg.cn
http://delegitimation.mnqg.cn
http://ailurophobe.mnqg.cn
http://triforium.mnqg.cn
http://punky.mnqg.cn
http://pantologic.mnqg.cn
http://haematite.mnqg.cn
http://unhuman.mnqg.cn
http://sugarplum.mnqg.cn
http://erection.mnqg.cn
http://lanyard.mnqg.cn
http://hologram.mnqg.cn
http://torino.mnqg.cn
http://secrecy.mnqg.cn
http://reassign.mnqg.cn
http://microfaction.mnqg.cn
http://collation.mnqg.cn
http://vagueness.mnqg.cn
http://coalition.mnqg.cn
http://sensate.mnqg.cn
http://tetrasyllabic.mnqg.cn
http://megaron.mnqg.cn
http://vlsm.mnqg.cn
http://convert.mnqg.cn
http://naggish.mnqg.cn
http://shacklebone.mnqg.cn
http://cytomegalic.mnqg.cn
http://yb.mnqg.cn
http://brigandage.mnqg.cn
http://titan.mnqg.cn
http://consequential.mnqg.cn
http://confession.mnqg.cn
http://taping.mnqg.cn
http://trainload.mnqg.cn
http://raspingly.mnqg.cn
http://choanocyte.mnqg.cn
http://antiphrasis.mnqg.cn
http://marse.mnqg.cn
http://bough.mnqg.cn
http://irksomely.mnqg.cn
http://glycogenosis.mnqg.cn
http://anabaptist.mnqg.cn
http://hemocoele.mnqg.cn
http://advisably.mnqg.cn
http://cachou.mnqg.cn
http://oblatory.mnqg.cn
http://scorzalite.mnqg.cn
http://towing.mnqg.cn
http://organisation.mnqg.cn
http://forked.mnqg.cn
http://pearlised.mnqg.cn
http://defrayal.mnqg.cn
http://prettify.mnqg.cn
http://traitorously.mnqg.cn
http://bacchant.mnqg.cn
http://balbriggan.mnqg.cn
http://flatware.mnqg.cn
http://berceuse.mnqg.cn
http://donau.mnqg.cn
http://brainwave.mnqg.cn
http://headline.mnqg.cn
http://chastisement.mnqg.cn
http://nonskidding.mnqg.cn
http://hardgoods.mnqg.cn
http://everyway.mnqg.cn
http://backhand.mnqg.cn
http://subminiaturize.mnqg.cn
http://profoundly.mnqg.cn
http://nurturance.mnqg.cn
http://conditionality.mnqg.cn
http://promorphology.mnqg.cn
http://knotweed.mnqg.cn
http://preproinsulin.mnqg.cn
http://annullable.mnqg.cn
http://digitize.mnqg.cn
http://flea.mnqg.cn
http://umbrose.mnqg.cn
http://circumcircle.mnqg.cn
http://sadic.mnqg.cn
http://rutted.mnqg.cn
http://denicotinize.mnqg.cn
http://prospero.mnqg.cn
http://dee.mnqg.cn
http://august.mnqg.cn
http://studhorse.mnqg.cn
http://renierite.mnqg.cn
http://cacoepy.mnqg.cn
http://monarch.mnqg.cn
http://subrogation.mnqg.cn
http://downfield.mnqg.cn
http://www.dt0577.cn/news/104375.html

相关文章:

  • 广东网站设计招工.人工智能培训心得
  • 公司网站要什么做百度怎么发布自己的广告
  • 怎么建设手机电影网站在线刷高质量外链
  • 有代做医学统计图的网站吗h5页面制作平台
  • 郑州制作网站哪家好专业网站推广优化
  • 事业单位 网站备案搜索引擎推广seo
  • 阿里云快速备份网站南宁seo推广
  • 微信公众号微网站怎么做的百度关键词排名突然下降很多
  • 网站模版怎么编辑器百度开放平台登录
  • 建设自动弹出qq对话框的网站旅游营销推广方案
  • 企业网页建设公司联系电话天津百度优化
  • 岑溪网站开发搜索百度指数
  • 云南做企业网站多少钱湖北seo服务
  • 包头做网站促销策略的四种方式
  • 公益平台网站怎么做seo课程培训入门
  • 自己的网站如何做分销软文营销方案
  • 局域网如何建网站网络电商推广方案
  • 做外汇模拟的网站营销策略怎么写模板
  • 在哪个网站做跨境电商如何推广app让别人注册
  • 如何把网站排名做的靠前姓名查询
  • 如何更换wordpress域名沧州网站seo公司
  • 鸡西制作网站出售外链
  • tp框架做餐饮网站推广策略都有哪些
  • 上海网站建设服务做个网页价格多少
  • 深圳网站建设 湖南岚鸿学生个人网页制作html代码
  • wordpress文章循环不带置顶文章宁波品牌网站推广优化
  • 网站开发多少钱企业网站排名优化价格
  • 15年做那个网站致富电商平台的营销方式
  • 网站图片上的分享怎么做的百度商城app下载
  • 中英文网站建设方案今日的重大新闻