QT第四天

要求:使用QT完成计算器UI设计,如下图:

程序运行结果:

 

代码:

 mainwindow.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>MainWindow</class><widget class="QMainWindow" name="MainWindow"><property name="geometry"><rect><x>0</x><y>0</y><width>540</width><height>960</height></rect></property><property name="windowTitle"><string>计算器</string></property><widget class="QWidget" name="centralwidget"><layout class="QVBoxLayout" name="verticalLayout_3" stretch="2,1,1,1,1,2"><item><widget class="QLabel" name="label"><property name="sizePolicy"><sizepolicy hsizetype="Preferred" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="layoutDirection"><enum>Qt::LeftToRight</enum></property><property name="text"><string>=</string></property></widget></item><item><layout class="QHBoxLayout" name="horizontalLayout"><item><widget class="QPushButton" name="pushButton_4"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>MC</string></property></widget></item><item><widget class="QPushButton" name="pushButton_3"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>MR</string></property></widget></item><item><widget class="QPushButton" name="pushButton_2"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>MS</string></property></widget></item><item><widget class="QPushButton" name="pushButton_5"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>M+</string></property></widget></item><item><widget class="QPushButton" name="pushButton"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>M-</string></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="horizontalLayout_2"><item><widget class="QPushButton" name="pushButton_6"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>←</string></property></widget></item><item><widget class="QPushButton" name="pushButton_7"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>CE</string></property></widget></item><item><widget class="QPushButton" name="pushButton_8"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>C</string></property></widget></item><item><widget class="QPushButton" name="pushButton_9"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>±</string></property></widget></item><item><widget class="QPushButton" name="pushButton_10"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>√</string></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="horizontalLayout_3"><item><widget class="QPushButton" name="pushButton_11"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>7</string></property></widget></item><item><widget class="QPushButton" name="pushButton_12"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>8</string></property></widget></item><item><widget class="QPushButton" name="pushButton_13"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>9</string></property></widget></item><item><widget class="QPushButton" name="pushButton_14"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>/</string></property></widget></item><item><widget class="QPushButton" name="pushButton_15"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>%</string></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="horizontalLayout_4"><property name="topMargin"><number>0</number></property><item><widget class="QPushButton" name="pushButton_16"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>4</string></property></widget></item><item><widget class="QPushButton" name="pushButton_17"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>5</string></property></widget></item><item><widget class="QPushButton" name="pushButton_18"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>6</string></property></widget></item><item><widget class="QPushButton" name="pushButton_19"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>*</string></property></widget></item><item><widget class="QPushButton" name="pushButton_20"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>1/x</string></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="horizontalLayout_5" stretch="2,2,1"><property name="spacing"><number>6</number></property><item><layout class="QVBoxLayout" name="verticalLayout_2"><property name="rightMargin"><number>0</number></property><item><layout class="QHBoxLayout" name="horizontalLayout_13" stretch="0,0"><property name="rightMargin"><number>0</number></property><item><widget class="QPushButton" name="pushButton_35"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>1</string></property></widget></item><item><widget class="QPushButton" name="pushButton_34"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>2</string></property></widget></item></layout></item><item><widget class="QPushButton" name="pushButton_36"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>0</string></property></widget></item></layout></item><item><layout class="QVBoxLayout" name="verticalLayout"><property name="rightMargin"><number>0</number></property><item><layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,0"><property name="spacing"><number>6</number></property><property name="leftMargin"><number>0</number></property><property name="rightMargin"><number>0</number></property><item><widget class="QPushButton" name="pushButton_23"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>3</string></property></widget></item><item><widget class="QPushButton" name="pushButton_22"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>-</string></property></widget></item></layout></item><item><layout class="QHBoxLayout" name="horizontalLayout_12"><property name="spacing"><number>6</number></property><property name="leftMargin"><number>0</number></property><property name="rightMargin"><number>0</number></property><item><widget class="QPushButton" name="pushButton_32"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>.</string></property></widget></item><item><widget class="QPushButton" name="pushButton_33"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>+</string></property></widget></item></layout></item></layout></item><item><widget class="QPushButton" name="pushButton_21"><property name="sizePolicy"><sizepolicy hsizetype="Minimum" vsizetype="Expanding"><horstretch>0</horstretch><verstretch>0</verstretch></sizepolicy></property><property name="text"><string>=</string></property></widget></item></layout></item></layout></widget><widget class="QMenuBar" name="menubar"><property name="geometry"><rect><x>0</x><y>0</y><width>540</width><height>28</height></rect></property><widget class="QMenu" name="menuview"><property name="title"><string>查看(V)</string></property></widget><widget class="QMenu" name="menuedit"><property name="title"><string>编辑(E)</string></property></widget><widget class="QMenu" name="menuhelp"><property name="title"><string>帮助(H)</string></property></widget><addaction name="menuview"/><addaction name="menuedit"/><addaction name="menuhelp"/></widget><widget class="QStatusBar" name="statusbar"/></widget><resources/><connections/>
</ui>

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

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

相关文章

MQTT在Web开发中的应用

前文写了使用Docker部署了mqtt服务&#xff0c;今天来写一下&#xff0c;mqtt在web开发中的应用实例&#xff0c;希望能帮到大家&#xff0c;话不多说&#xff0c;直接开始。 一&#xff1a;脚手架安装mqtt 作者这里用的vue3的框架 直接上命令&#xff0c;npm安装或者pnpm进行…

使用pycharm连接读取orcl数据库的表

背景&#xff1a;工作需要 需求&#xff1a;使用pycharm访问远程oracle类型数据库的表&#xff0c;表中包含lob字段&#xff08;这也是个坑&#xff01;&#xff09; 麻了&#xff0c;搞了一个星期&#xff0c;终于成功了&#xff0c;真可谓是每步都有坑&#xff0c;看的文章也…

Microsoft365管理员创建共享邮箱

​​​​​​ 创建共享邮箱 项目2023/08/2110 个参与者 反馈 本文内容 创建共享邮箱并添加成员您应使用哪些权限&#xff1f;阻止登录共享邮箱帐户向 Outlook 添加共享邮箱 显示另外 3 个 备注 如果你的组织使用的是混合 Exchange 环境&#xff0c;则你应使用本地 Excha…

SSH数据流量监控

简介 检查网络连接的数据传输情况有以下一些实际意义&#xff1a; 安全监控&#xff1a;检查数据传输情况可以帮助你识别异常活动或潜在的安全威胁。如果发现大量不寻常的数据传输活动&#xff0c;可能表示有未经授权的访问或恶意行为。通过监控数据传输&#xff0c;可以及时发…

SQLite 3.45.0 发布!

SQLite 开发团队于 2024 年 01 月 18 日发布了 SQLite 3.45.0 版本&#xff0c;带来了一些 JSON 和优化器增强&#xff0c;让我们一睹为快&#xff01; JSON 函数 SQLite 3.45.0 版本开始&#xff0c;所有的 JSON 函数将会使用全新的内部格式存储 JSON 数据&#xff0c;也就是…

服务器工作环境要求

在开展网站服务之前&#xff0c;合适的服务器工作环境是必不可少的。服务器工作环境指需要一定的软硬件条件来保障服务器可以正常地运转和提供高效率的服务。在这篇文章中&#xff0c;我们将会详细讲解服务器工作环境所需的要素。 一、硬件要求 服务器硬件方面包括了基本的电…

网络 - 网速很慢一定是网不好引起的吗?

问题描述 网速很慢一定是网不好引起的吗&#xff1f;其实不然&#xff0c;也有可能跟 DNS 有关噢~ 原因分析 一开始以为开了小飞机&#xff0c;导致网络不好&#xff0c;发现关闭了还是这样&#xff0c;后来摸索了老半天发现&#xff0c;会不会是 DNS 解析服务器不给力引起的…

阿里云地域和可用区分布表,2024更新

2024年阿里云服务器地域分布表&#xff0c;地域指数据中心所在的地理区域&#xff0c;通常按照数据中心所在的城市划分&#xff0c;例如华北2&#xff08;北京&#xff09;地域表示数据中心所在的城市是北京。阿里云地域分为四部分即中国、亚太其他国家、欧洲与美洲和中东&…

周五~~~摸鱼

学习也能很快乐哦~~&#xff01; vim /etc/motd 修改这个文件可以让你刚登录linux 系统显示图形效果 佛祖 效果&#xff1a; 自行车 效果&#xff1a; love \ ------------ / ------ \ \ …

Java中位运算右移>>和>>>的区别

在Java编程语言中&#xff0c;>> 和 >>> 都是右移运算符&#xff0c;但它们有以下区别&#xff1a; 算术右移&#xff08;Arithmetic Right Shift, >>&#xff09;&#xff1a; 当对一个有符号整数进行右移时&#xff0c;Java使用的是算术右移。这意味着…

Android ANR 总结

工作之余&#xff0c;对之前学习到的和结合自己项目过程中的遇到的问题经验做一些总结&#xff0c;下面讲一讲Android开发过程中遇到的ANR的问题&#xff0c;做一下整理 一、概述 解决ANR一直是Android 开发者需要掌握的重要技巧&#xff0c;一般从三个方面着手。 开发阶段&a…

CMake TcpServer项目 生成静态库.a / 动态库.so

CMake 实战构建TcpServer项目 静态库/动态库-CSDN博客https://blog.csdn.net/weixin_41987016/article/details/135608829?spm1001.2014.3001.5501 在这篇博客的基础上&#xff0c;我们把头文件放在include里边&#xff0c;把源文件放在src里边&#xff0c;重新构建 hehedali…

区间预测 | Matlab实现LSTM-Adaboost-ABKDE的集成学习长短期记忆神经网络自适应带宽核密度估计多变量回归区间预测

区间预测 | Matlab实现LSTM-Adaboost-ABKDE的集成学习长短期记忆神经网络自适应带宽核密度估计多变量回归区间预测 目录 区间预测 | Matlab实现LSTM-Adaboost-ABKDE的集成学习长短期记忆神经网络自适应带宽核密度估计多变量回归区间预测效果一览基本介绍程序设计参考资料 效果一…

五个常见的 jQuery 面试题

1. 如何使用 jQuery 选择器选中所有 class 为 “example” 的元素? $(".example");2. 如何使用 jQuery 遍历一个数组&#xff0c;并将每个元素添加到一个 <ul> 列表中? <ul id"list"></ul>var array ["Item 1", "It…

Plane Geometry (Junior High School)

初中平面几何&#xff0c; ACBD, ∠CAD60&#xff0c;∠C40&#xff0c;求∠B Vertical Calculation-CSDN博客 Rectangular Area-CSDN博客

开发安全之:Password Management: Hardcoded Password

Overview Hardcoded password 可能会削弱系统安全性&#xff0c;并且无法轻易修正出现的安全问题。 Details 使用硬编码方式处理密码绝非好方法。这不仅是因为所有项目开发人员都可以使用通过硬编码方式处理的密码&#xff0c;而且还会使解决这一问题变得极其困难。在代码投…

kafka系列(二)

本章承接kafka一内容&#xff0c;文章在本人博客主页都有&#xff0c;可以自行点击浏览。 幂等性 请求执行多次&#xff0c;但执行的结果是一致的。 如果&#xff0c;某个系统是不具备幂等性的&#xff0c;如果用户重复提交了某个表格&#xff0c;就可能会造成不良影响。例如…

街机模拟游戏逆向工程(HACKROM)教程:[10]68K汇编add指令

我们之前已经介绍了move指令&#xff0c;从本章开始&#xff0c;我们会一步步介绍更多的M68K指令。 简介&#xff1a; add :加法指令 该指令的作用是[源操作数]加[目的操作数]&#xff0c;结果传递至[目的操作数]&#xff0c;[源操作数]保持不变。 例子&#xff1a;…

基于改进蝙蝠算法的三维航线规划算法

matlab2020a可正常运行 基于改进蝙蝠算法的三维航线规划资源-CSDN文库

Oracle 数据库备份与恢复的重要性与最佳实践

文章目录 一、备份的重要性二、备份工具-RMAN四、比较备份策略五、实例恢复六、完全恢复与不完全恢复七、备份与恢复脚本 引言&#xff1a; 在现代信息时代&#xff0c;数据已成为组织和企业最重要的资产之一。保护和恢复数据的能力对于确保业务连续性和减少潜在风险至关重要。…