qt-C++笔记之滑动条QSlider和QProgressBar进度条

qt-C++笔记之滑动条QSlider和QProgressBar进度条

—— 2024-04-28 杭州

本例来自《Qt6 C++开发指南》

文章目录

  • qt-C++笔记之滑动条QSlider和QProgressBar进度条
    • 1.运行
    • 2.阅读笔记
    • 3.文件结构
    • 4.samp4_06.pro
    • 5.main.cpp
    • 6.widget.h
    • 7.widget.cpp
    • 8.widget.ui

1.运行

在这里插入图片描述

2.阅读笔记

在这里插入图片描述

在这里插入图片描述

3.文件结构

在这里插入图片描述

4.samp4_06.pro

QT       += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++11# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \main.cpp \widget.cppHEADERS += \widget.hFORMS += \widget.ui# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

5.main.cpp

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

6.widget.h

#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();private slots://自定义槽函数void do_valueChanged(int value);void on_chkBox_Visible_clicked(bool checked);void on_chkBox_Inverted_clicked(bool checked);void on_radio_Percent_clicked();void on_radio_Value_clicked();private:Ui::Widget *ui;
};#endif // WIDGET_H

7.widget.cpp

#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
{ui->setupUi(this);//将表盘,滑动条,卷滚条的valueChanged()信号与自定义槽函数关联connect(ui->slider,SIGNAL(valueChanged(int)),this, SLOT(do_valueChanged(int)));connect(ui->scrollBar,SIGNAL(valueChanged(int)),this, SLOT(do_valueChanged(int)));connect(ui->dial,SIGNAL(valueChanged(int)),this, SLOT(do_valueChanged(int)));}Widget::~Widget()
{delete ui;
}void Widget::do_valueChanged(int value)
{//自定义槽函数ui->progressBar->setValue(value);
}void Widget::on_chkBox_Visible_clicked(bool checked)
{//textVisibleui->progressBar->setTextVisible(checked);
}void Widget::on_chkBox_Inverted_clicked(bool checked)
{//InvertedAppearanceui->progressBar->setInvertedAppearance(checked);
}void Widget::on_radio_Percent_clicked()
{//显示格式--百分比ui->progressBar->setFormat("%p%");
}void Widget::on_radio_Value_clicked()
{//显示格式--当前值ui->progressBar->setFormat("%v");
}

8.widget.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Widget</class><widget class="QWidget" name="Widget"><property name="geometry"><rect><x>0</x><y>0</y><width>436</width><height>299</height></rect></property><property name="font"><font><pointsize>10</pointsize></font></property><property name="windowTitle"><string>Slider和ProgreeeBar</string></property><layout class="QVBoxLayout" name="verticalLayout_2"><item><widget class="QGroupBox" name="groupBox"><property name="title"><string>滑动输入</string></property><layout class="QHBoxLayout" name="horizontalLayout_2"><item><widget class="QDial" name="dial"><property name="maximum"><number>200</number></property><property name="value"><number>20</number></property><property name="orientation"><enum>Qt::Horizontal</enum></property><property name="wrapping"><bool>false</bool></property><property name="notchTarget"><double>5.000000000000000</double></property><property name="notchesVisible"><bool>true</bool></property></widget></item><item><layout class="QGridLayout" name="gridLayout_2"><item row="0" column="0"><widget class="QLabel" name="label"><property name="text"><string>滑动条</string></property></widget></item><item row="0" column="1"><widget class="QSlider" name="slider"><property name="maximum"><number>200</number></property><property name="value"><number>23</number></property><property name="orientation"><enum>Qt::Horizontal</enum></property><property name="tickPosition"><enum>QSlider::TicksAbove</enum></property></widget></item><item row="1" column="0"><widget class="QLabel" name="label_2"><property name="text"><string>卷滚条</string></property></widget></item><item row="1" column="1"><widget class="QScrollBar" name="scrollBar"><property name="maximum"><number>200</number></property><property name="value"><number>23</number></property><property name="orientation"><enum>Qt::Horizontal</enum></property></widget></item></layout></item></layout></widget></item><item><widget class="QGroupBox" name="groupBox_2"><property name="title"><string>ProgressBar显示和设置</string></property><layout class="QVBoxLayout" name="verticalLayout"><item><widget class="QFrame" name="frame"><layout class="QHBoxLayout" name="horizontalLayout"><property name="leftMargin"><number>2</number></property><property name="topMargin"><number>2</number></property><property name="rightMargin"><number>2</number></property><property name="bottomMargin"><number>0</number></property><item><widget class="QLabel" name="label_3"><property name="text"><string>进度条</string></property></widget></item><item><widget class="QProgressBar" name="progressBar"><property name="maximum"><number>200</number></property><property name="value"><number>24</number></property></widget></item></layout></widget></item><item><widget class="QFrame" name="frame_2"><property name="frameShadow"><enum>QFrame::Raised</enum></property><layout class="QGridLayout" name="gridLayout"><item row="1" column="1"><widget class="QRadioButton" name="radio_Value"><property name="text"><string>显示格式--当前值</string></property><property name="checked"><bool>false</bool></property></widget></item><item row="1" column="0"><widget class="QRadioButton" name="radio_Percent"><property name="text"><string>显示格式--百分比</string></property><property name="checked"><bool>true</bool></property></widget></item><item row="0" column="1"><widget class="QCheckBox" name="chkBox_Inverted"><property name="text"><string>invertedAppearance</string></property></widget></item><item row="0" column="0"><widget class="QCheckBox" name="chkBox_Visible"><property name="text"><string>textVisible</string></property><property name="checked"><bool>true</bool></property></widget></item></layout></widget></item></layout></widget></item></layout></widget><layoutdefault spacing="6" margin="11"/><resources/><connections/>
</ui>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/4682.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

RuoYi-Vue-Plus (SPEL 表达式)

RuoYi-Vue-Plus 中SPEL使用 DataScopeType 枚举类中&#xff1a; /*** 部门数据权限*/DEPT("3", " #{#deptName} #{#user.deptId} ", " 1 0 "), PlusDataPermissionHandler 拦截器中定义了解析器&#xff1a; buildDataFilter 方法中根据注解的…

[LitCTF 2023]Ping、[SWPUCTF 2021 新生赛]error、[NSSCTF 2022 Spring Recruit]babyphp

[LitCTF 2023]Ping 尝试ping一下127.0.0.1成功了&#xff0c;但要查看根目录时提示只能输入IP 查看源代码&#xff0c;这段JavaScript代码定义了一个名为check_ip的函数&#xff0c;用于验证输入是否为有效的IPv4地址。并且使用正则表达式re来匹配IPv4地址的格式。 对于这种写…

机器学习:基于Sklearn、XGBoost框架,使用逻辑回归、支持向量机和XGBClassifier预测帕金森病

前言 系列专栏&#xff1a;机器学习&#xff1a;高级应用与实践【项目实战100】【2024】✨︎ 在本专栏中不仅包含一些适合初学者的最新机器学习项目&#xff0c;每个项目都处理一组不同的问题&#xff0c;包括监督和无监督学习、分类、回归和聚类&#xff0c;而且涉及创建深度学…

【已解决】Python Selenium chromedriver Pycharm闪退的问题

概要 根据不同的业务场景需求&#xff0c;有时我们难免会使用程序来打开浏览器进行访问。本文在pycharm中使用selenium打开chromedriver出现闪退问题&#xff0c;根据不断尝试&#xff0c;最终找到的问题根本是版本问题。 代码如下 # (1) 导入selenium from selenium import …

科研学习|论文解读——CVPR 2021 人脸造假检测(论文合集)

随着图像合成技术的成熟&#xff0c;利用一张人脸照片合成假视频/不良视频现象越来越多&#xff0c;严重侵犯个人隐私、妨碍司法公正&#xff0c;所以人脸造假检测越来越重要&#xff0c;学术界的论文也越来越多。 一、研究1 1.1 论文题目 Multi-attentional Deepfake Detecti…

自学Python爬虫js逆向(二)chrome浏览器开发者工具的使用

js逆向中很多工作需要使用浏览器中的开发者工具&#xff0c;所以这里以chrome为例&#xff0c;先把开发者工具的使用总结一下&#xff0c;后面用到的时候可以回来查询。 Google Chrome浏览器的开发者工具是前端开发者的利器&#xff0c;它不仅提供了丰富的功能用于开发、调试和…

什么是中间件?中间件有哪些?

什么是中间件&#xff1f; 中间件&#xff08;Middleware&#xff09;是指在客户端和服务器之间的一层软件组件&#xff0c;用于处理请求和响应的过程。 中间件是指介于两个不同系统之间的软件组件&#xff0c;它可以在两个系统之间传递、处理、转换数据&#xff0c;以达到协…

排序算法(2)快排

交换排序 思想&#xff1a;所谓交换&#xff0c;就是根据序列中两个记录键值的比较结果来对换这两个记录在序列中的位置&#xff0c;交换排序的特点是&#xff1a;将键值较大的记录向序列的尾部移动&#xff0c;键值较小的记录向序列的前部移动。 一、冒泡排序 public static…

uniapp:K线图,支持H5,APP

使用KLineChart完成K线图制作,完成效果: 1、安装KLineChart npm install klinecharts2、页面中使用 <template><view class="index"><!-- 上方选项卡 --><view class="kline-tabs"><view :style="{color: current==ite…

stm32单片机开发四、USART

串口的空闲状态时高电平&#xff0c;起始位是低电平&#xff0c;来打破空闲状态的高电平 必须要有停止位&#xff0c;停止位一般为一位高电平 串口常说的数据为8N1&#xff0c;其实就是8个数据位&#xff08;固定的&#xff09;&#xff0c;N就是none&#xff0c;也就是0个校验…

【多模态大模型】AI对视频内容解析问答

文章目录 1. 项目背景2. 直接对视频进行解析进行AI问答&#xff1a;MiniGPT4-Video2.1 MiniGPT4-Video效果 3. 对视频抽帧为图片再进行AI问答3.1 视频抽帧3.2 图片AI问答3.2.1 阿里通义千问大模型 Qwen-vl-plus3.2.2 Moonshot 1. 项目背景 最近在做一个项目,需要使用AI技术对视…

618科技嘉年华!五款极致科技产品,开启智能生活新篇章!

准备好迎接一年一度的618了吗&#xff1f;这不仅仅是一场购物的狂欢&#xff0c;更是一次科技的盛宴&#xff0c;一次智能生活的全新启航。今年&#xff0c;我们将带来五款令人瞩目的极致科技产品&#xff0c;它们将彻底颠覆你对智能生活的认知。从娱乐到工作&#xff0c;这些产…

百度语音识别的springboot应用

1、pom依赖 <dependency> <groupId>com.baidu.aip</groupId> <artifactId>java-sdk</artifactId> <version>4.16.18</version> </dependency> 2、测试的demo 创建语音识别应用 百度智能云-管理中心 (baidu.com) 代码中要…

常用图像加密技术-流密码异或加密

异或加密是最常用的一种加密方式&#xff0c;广泛的适用于图像处理领域。这种加密方式依据加密密钥生成伪随机序列与图像的像素值进行异或操作&#xff0c;使得原像素值发生变化&#xff0c;进而使得图像内容发生变化&#xff0c;达到保护图像内容的目的。 该加密方法是以图像…

基于python-flask技术的社区信息交流平台【数据库+15000文档】

预览 介绍 系统只需使用者通过电脑浏览器即可实现系统的访问和操作的WEB模式的信息化系统。为了保证系统数据的准确性、安全性的数据存储&#xff0c;系统应用MySQL数据库进行系统数据存储服务。根据对社区工作的深入调研和对社区居民的走访调查&#xff0c;详细分析整体系统的…

短信验证码绕过漏洞(一)

短信验证码绕过漏洞 0x01原理&#xff1a; 服务器端返回的相关参数作为最终登录凭证&#xff0c;导致可绕过登录限制。 危害&#xff1a;在相关业务中危害也不同&#xff0c;如找回密码&#xff0c;注册&#xff0c;电话换绑等地方即可形成高危漏洞&#xff0c;如果是一些普…

【VS+QT】visual studio 2022配置和搭建QT

一、下载QT 可以去QT官网下载:https://www.qt.io/product/development-tools。 直接安装。 二、安装qt插件 打开visual studio 2022&#xff0c;选择菜单栏中扩展->管理扩展 ,然后直接在vs插件市场搜索Qt Visual Studio Tools就行。 安装的时候根据提示&#xff0c;关闭…

YOLov5 + Gradio搭建简单的Web GUI

写在前面&#xff1a;当我们将模型训练出来了&#xff0c;此时就需要做UI界面给别人展示了。python提供的Gradio可以快速的搭建web页面。生成本地网址和公网网址&#xff0c;方面自己测试和用户测试。 一、安装 Gradio介绍 Gradio是一个开源的python库&#xff0c;用于构建机…

react完整项目搭建的思路

react完整项目搭建的思路 react完整项目搭建的思路1.使用creacte-react-app初始化项目2.安装所需插件:路由、网络、样式、组件库3.reactjs目录结构组织4. 配置路径别名4.配置路由5.网络配置,对axios进行封装》获取当前环境变量 6.配置代理解决跨域7.配置使用iconfont8.状态管理…

浅析扩散模型与图像生成【应用篇】(十七)——LDM

17. High-Resolution Image Synthesis with Latent Diffusion Models 该文首次提出在潜在特征空间中的扩散模型LDM&#xff0c;也是大名鼎鼎的Stable Diffusion&#xff08;SD&#xff09;模型的基础。不同于之前的扩散模型直接在图像维度上进行扩散和去噪&#xff0c;LDM首先训…