中国建设银行官方网站app下载,建设银行安徽分行招聘网站,建设垂直网站需要哪些流程图,江苏省城乡建设局网站Lambda 介绍 Lambda 函数也叫匿名函数#xff0c; 是C 11中新增的特性;谁用谁知道#xff0c;哈#xff1b; 1. Lambda函数的好处
Lambda函数使代码变得更加紧凑、更加结构化和更富有表现力#xff1b;
lambda在c作用主要是作为内嵌函数#xff0c;逻辑更加清楚#xf…Lambda 介绍 Lambda 函数也叫匿名函数 是C 11中新增的特性;谁用谁知道哈 1. Lambda函数的好处
Lambda函数使代码变得更加紧凑、更加结构化和更富有表现力
lambda在c作用主要是作为内嵌函数逻辑更加清楚代码可读性更好
【QT】Qt之QFutureWatcher
简述
QFuture 表示异步计算的结果QFutureWatcher 则允许使用信号和槽监视 QFuture也就是说QFutureWatcher 是为 QFuture 而生的。
// 实例化对象并连接到 finished() 信号。
MyClass myObject;
QFutureWatcherint watcher;
connect(watcher, SIGNAL(finished()), myObject, SLOT(handleFinished()));// 开始计算
QFutureint future QtConcurrent::run(...);
watcher.setFuture(future); 使用 lambda if(nullptr WidgetWatcher){WidgetWatcher new QFutureWatchervoid;connect(WidgetWatcher, QFutureWatchervoid::finished, this, []() {qDebug()finish threadid QThread::currentThreadId();mQProgressDialog-close();});}QFuturevoid future QtConcurrent::run([]() {//slotShowInsertionWidget();qDebug()111 threadid QThread::currentThreadId();QThread::sleep(3);getTextStaticFun();});WidgetWatcher-setFuture(future);
传参
// 传入 当前 this
QFuturevoid future QtConcurrent::run([]()
还可以使用 QProgressDialog 作为阻堵 函数变成同步 progress-exec();
完成后关闭 connect(WidgetWatcher, QFutureWatchervoid::finished, this, []() {qDebug()finish threadid QThread::currentThreadId();mQProgressDialog-close();});
MyQProgressDialog
#ifndef MYPROGRESSDIALOG_H
#define MYPROGRESSDIALOG_H#includeQProgressDialog
class MyProgressDialog :public QProgressDialog
{Q_OBJECT
public:MyProgressDialog(const QString labelText);
};#include myprogressdialog.h
#includeQProgressBar
MyProgressDialog::MyProgressDialog(const QString labelText)
{setAutoClose(false); //进度达到最大值时不关闭默认为true// setLabelText(正在导出数据请稍后...); //显示的文本setLabelText(labelText);setCancelButton(NULL); //不显示取消按钮setWindowModality(Qt::WindowModal);//mQProgressDialog-setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::WindowStaysOnTopHint);setMinimumWidth(600);// setWindowModality(Qt::ApplicationModal);//setModal(true);QProgressBar * prog new QProgressBar(this);prog-setTextVisible(false);//prog-setStyleSheet(QProgressBar{ max-height: 20px;\nbackground: #323232;\nborder-radius: 10px;\ntext-align:center;\n}\nQProgressBar::chunk { background: #2C6ED5;\nborder-radius: 10px;\n});prog-setRange(0, 0);setBar(prog);//mQProgressDialog-hide();reset();
}