没有合适的资源?快使用搜索试试~ 我知道了~
QT5网格布局简单计算器
4星 · 超过85%的资源 需积分: 17 20 下载量 2 浏览量
2015-05-07
13:26:05
上传
评论 1
收藏 9KB TXT 举报
温馨提示
简单地利用QT的网格布局,文档里有pro .h .cpp main除了利用网格布局,计算部分使用QString转成double型,输出文本框用double再转成QString
资源推荐
资源详情
资源评论
/**********************pro*********************/
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = wangge
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
/***********************cpp**********************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
A="0";
B="0";
fuhao=' ';
this->setWindowTitle("calculator");
l = new QLineEdit(this);
l->setText(B);
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = wangge
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
/***********************cpp**********************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
A="0";
B="0";
fuhao=' ';
this->setWindowTitle("calculator");
l = new QLineEdit(this);
l->setText(B);
gridLayout = new QGridLayout();
button1 = new QPushButton("1");
button2 = new QPushButton("2");
button3 = new QPushButton("3");
button4 = new QPushButton("4");
button5 = new QPushButton("5");
button6 = new QPushButton("6");
button7 = new QPushButton("7");
button8 = new QPushButton("8");
button9 = new QPushButton("9");
button0 = new QPushButton("0");
buttonjia = new QPushButton("+");
buttonjian = new QPushButton("-");
buttondengyu = new QPushButton("=");
buttonchen = new QPushButton("*");
buttonchu = new QPushButton("/");
buttonguiling = new QPushButton("C");
buttondian = new QPushButton(".");
gridLayout->addWidget(buttonguiling,2,0,1,5);
gridLayout->addWidget(button1,5,0,1,1);
gridLayout->addWidget(button2,5,1,1,1);
gridLayout->addWidget(button3,5,2,1,1);
gridLayout->addWidget(button4,4,0,1,1);
gridLayout->addWidget(button5,4,1,1,1);
gridLayout->addWidget(button6,4,2,1,1);
gridLayout->addWidget(button7,3,0,1,1);
gridLayout->addWidget(button8,3,1,1,1);
gridLayout->addWidget(button9,3,2,1,1);
gridLayout->addWidget(button0,6,0,1,2);
gridLayout->addWidget(buttonjia,4,3,1,2);
button1 = new QPushButton("1");
button2 = new QPushButton("2");
button3 = new QPushButton("3");
button4 = new QPushButton("4");
button5 = new QPushButton("5");
button6 = new QPushButton("6");
button7 = new QPushButton("7");
button8 = new QPushButton("8");
button9 = new QPushButton("9");
button0 = new QPushButton("0");
buttonjia = new QPushButton("+");
buttonjian = new QPushButton("-");
buttondengyu = new QPushButton("=");
buttonchen = new QPushButton("*");
buttonchu = new QPushButton("/");
buttonguiling = new QPushButton("C");
buttondian = new QPushButton(".");
gridLayout->addWidget(buttonguiling,2,0,1,5);
gridLayout->addWidget(button1,5,0,1,1);
gridLayout->addWidget(button2,5,1,1,1);
gridLayout->addWidget(button3,5,2,1,1);
gridLayout->addWidget(button4,4,0,1,1);
gridLayout->addWidget(button5,4,1,1,1);
gridLayout->addWidget(button6,4,2,1,1);
gridLayout->addWidget(button7,3,0,1,1);
gridLayout->addWidget(button8,3,1,1,1);
gridLayout->addWidget(button9,3,2,1,1);
gridLayout->addWidget(button0,6,0,1,2);
gridLayout->addWidget(buttonjia,4,3,1,2);
剩余13页未读,继续阅读
资源评论
- cmjain2015-11-03用不了,打不开
yyymkyyyy1314
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C# Winform Excel 转 Chart示例视频
- uniapp-小程序-vue
- 台球检测11-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- 富芮坤FR8003作为主机连接FR8003抓包文件20241223-135206.pcapng
- 谷歌股票数据集,google股票数据集,Alphabet股份数据集(2004-2024)
- nuget 库官方下载包,可使用解压文件打开解压使用
- 非wine、原生Linux迅雷安装包deb文件,支持Ubuntu、UOS统信、深度Deepin、LinuxMint、Debain系通用
- KUKA机器人安装包,与PROFINET软件包
- 船舶燃料消耗和二氧化碳排放分析数据集,燃料消耗和碳排放关联分析数据
- req-sign、bd-ticket-ree-public加密算法(JS)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功