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

京东网上商城和京东有什么区别关键字排名优化工具

京东网上商城和京东有什么区别,关键字排名优化工具,新能源电动汽车价格表,网站美工切图是如何做的背景: 一开始是通过在主线程中写一个for循环,每次加1后睡眠1s进行进度条更新。但这样写的结果是 --> 无法动态显示进度条进度。后通过上一篇文章 [ QT5|C|通过信号槽机制实现进度条更新 ] 中的写信号槽机制实现。实现后 考虑了下有没有其他方式实现&a…

背景: 一开始是通过在主线程中写一个for循环,每次加1后睡眠1s进行进度条更新。但这样写的结果是 --> 无法动态显示进度条进度。后通过上一篇文章 [ QT5|C++|通过信号槽机制实现进度条更新 ] 中的写信号槽机制实现。实现后 考虑了下有没有其他方式实现,后想到了通过子线程方式。以下是通过子线程实现的具体事例:

功能: 
(1)点击【显示进度条进度】按钮,每隔1s动态加载进度条进度直到加载到100%;
(2)点击【退出】按钮,关闭当前对话框。

1、dialog.cpp

#include "dialog.h"
#include "ui_dialog.h"
#include<QPushButton>
//#include<QThread>
#include<thread>
#include<chrono>
#include<iostream>Dialog::Dialog(QWidget *parent): QDialog(parent), ui(new Ui::Dialog)
{ui->setupUi(this);connect(ui->quit_pushButton,&QPushButton::clicked,this,&QDialog::accept);ui->progressBar->setRange(1,100);std::thread myThread([=]{ThreadFunction();});myThread.detach();}void Dialog::ThreadFunction(){connect(ui->progressBar_pushButton,&QPushButton::clicked,this,[=]{for(auto i =1; i!=101 ;i++){ui->progressBar->setValue(i);std::this_thread::sleep_for(std::chrono::milliseconds(1000));}});
}Dialog::~Dialog()
{delete ui;
}

2、dialog.h

#ifndef DIALOG_H
#define DIALOG_H#include <QDialog>QT_BEGIN_NAMESPACE
namespace Ui { class Dialog; }
QT_END_NAMESPACEclass Dialog : public QDialog
{Q_OBJECTpublic:Dialog(QWidget *parent = nullptr);~Dialog();void ThreadFunction();private:Ui::Dialog *ui;
};
#endif // DIALOG_H

3、main.cpp

#include "dialog.h"#include <QApplication>int main(int argc, char *argv[])
{QApplication a(argc, argv);Dialog w;w.show();return a.exec();
}

4、Dialog.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Dialog</class><widget class="QDialog" name="Dialog"><property name="geometry"><rect><x>0</x><y>0</y><width>800</width><height>600</height></rect></property><property name="windowTitle"><string>Dialog</string></property><widget class="QWidget" name="verticalLayoutWidget"><property name="geometry"><rect><x>150</x><y>370</y><width>351</width><height>161</height></rect></property><layout class="QVBoxLayout" name="verticalLayout"><item><layout class="QHBoxLayout" name="horizontalLayout"><item><widget class="QPushButton" name="progressBar_pushButton"><property name="text"><string>显示进度条进度</string></property></widget></item><item><widget class="QPushButton" name="quit_pushButton"><property name="text"><string>退出</string></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="horizontalLayout_2"><item><widget class="QProgressBar" name="progressBar"><property name="value"><number>0</number></property></widget></item></layout></item></layout></widget></widget><resources/><connections/>
</ui>

注意事项:

1、在主线程的for循环中睡眠1s后更新会造成阻塞 不能直接写;
2、关于主线程中的控件,不要在子线程中进行设置,会阻塞主线程。
(关于这一点猜测的原因:qt内部机制 刷新不及时(虽然会阻塞,最终还是会更新完进度)。如果有大神了解具体原因,请详细介绍下,虚心学习)

显示效果:

子线程进度条

http://www.ahscrl.com/news/12808.html

相关文章:

  • 外国公司做网站网络营销就业前景和薪水
  • 网站域名注册证明第三方平台推广
  • wordpress主题制作插件seo优化检测
  • wordpress网站设计如何在百度上发表文章
  • 什么叫做响应式网站培训心得总结
  • 扫描二维码进入公司网站怎样做百度信息流推广平台
  • 新闻网站开发的意义百度助手app下载安装
  • 手机网页制作图片网站seo检测
  • 济南微网站开发优化设计答案大全
  • 做草莓的网站关键词分为哪几类
  • 网站怎么做第二个页面短视频seo
  • 网站建设用户登录源码国内搜索引擎排行榜
  • wordpress破解管理员帐号旺道智能seo系统
  • 自助建站系统建的网站做排名吗网站模板建站公司
  • 没有数据怎么做网站关键词优化案例
  • 长治网站制作厂家曼联vs曼联直播
  • 会员登录管理系统郴州seo
  • 网站定制开发要多少钱爱站关键词挖掘
  • 美食网站需求分析网页设计主要做什么
  • 网站二维码弹窗专注于网站营销服务
  • 类似织梦的建站cms湖南seo推广
  • 如何做制作头像的网站中国新闻最新消息今天
  • 外贸网站建设公司机构建站工具
  • 做网站要不要学ps营销方案ppt
  • 马鞍山做网站的公司78短视频推广平台
  • 教育网站制作运营网站怎么做优化排名
  • 国外网站页头设计图片谷歌google浏览器官方下载
  • 张掖网站建设郑州seo优化哪家好
  • 做网站比较好的公司有哪些自助网站建设平台
  • 网站和网页的区别sem工作内容