之前用C#的WPF写了一个平均绩点计算器,发到学校的贴吧里,反响还不错。不过没过几个月,就有人写了一个网络版的计算器,把我盖过去了。“既生瑜,何生亮?”开个玩笑。

转到Qt之后,学了一阵子,想练练手,就用Qt写了一个平均绩点计算器。

源码如下

mainwindow,h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include<QLineEdit>namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{Q_OBJECTpublic:explicit MainWindow(QWidget *parent = 0);~MainWindow();private:Ui::MainWindow *ui;double result;QList<QLineEdit*> LX,LJ;int count;public slots:void slot_add() ;void slot_cal();
};#endif // MAINWINDOW_H

mainwindow,cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QList>
#include<QString>MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow)
{ui->setupUi(this);count=2;LX.append(ui->LEX1);LX.append(ui->LEX2);LJ.append(ui->LEJ1);LJ.append(ui->LEJ2);connect(ui->cal,SIGNAL(clicked()),this,SLOT(slot_cal()));connect(ui->add,SIGNAL(clicked()),this,SLOT(slot_add()));}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::slot_add()
{count++;LX.append(new QLineEdit(this));LJ.append(new QLineEdit(this));ui->VLX->addWidget(LX[count-1]);ui->VLJ->addWidget(LJ[count-1]);}void MainWindow::slot_cal()
{double sum=0,sum2=0;for(int i=0;i<=count-1;i++)sum=sum+LX[i]->text().toInt();//zong xue fenfor(int i=0;i<=count-1;i++)sum2=sum2+(LX[i]->text().toDouble())*(LJ[i]->text().toDouble());ui->pjjd->setText(QString::number(sum2/sum));
}

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>520</width><height>405</height></rect></property><property name="palette"><palette><active><colorrole role="Base"><brush brushstyle="SolidPattern"><color alpha="255"><red>255</red><green>255</green><blue>255</blue></color></brush></colorrole><colorrole role="Window"><brush brushstyle="SolidPattern"><color alpha="255"><red>132</red><green>239</green><blue>240</blue></color></brush></colorrole></active><inactive><colorrole role="Base"><brush brushstyle="SolidPattern"><color alpha="255"><red>255</red><green>255</green><blue>255</blue></color></brush></colorrole><colorrole role="Window"><brush brushstyle="SolidPattern"><color alpha="255"><red>132</red><green>239</green><blue>240</blue></color></brush></colorrole></inactive><disabled><colorrole role="Base"><brush brushstyle="SolidPattern"><color alpha="255"><red>132</red><green>239</green><blue>240</blue></color></brush></colorrole><colorrole role="Window"><brush brushstyle="SolidPattern"><color alpha="255"><red>132</red><green>239</green><blue>240</blue></color></brush></colorrole></disabled></palette></property><property name="windowTitle"><string>平均绩点计算器</string></property><property name="windowIcon"><iconset resource="icon.qrc"><normaloff>:/cal.ico</normaloff>:/cal.ico</iconset></property><widget class="QWidget" name="centralWidget"><layout class="QGridLayout" name="gridLayout"><item row="1" column="3"><widget class="QLabel" name="label_2"><property name="text"><string>绩点</string></property></widget></item><item row="0" column="0"><widget class="QLabel" name="label_3"><property name="text"><string>平均绩点:</string></property></widget></item><item row="0" column="2"><widget class="QLabel" name="pjjd"><property name="text"><string>等待计算</string></property></widget></item><item row="0" column="4"><widget class="QPushButton" name="add"><property name="text"><string>增加</string></property></widget></item><item row="3" column="4"><widget class="QPushButton" name="cal"><property name="text"><string>计算</string></property></widget></item><item row="1" column="1"><widget class="QLabel" name="label"><property name="text"><string>学分</string></property></widget></item><item row="2" column="0" colspan="4"><widget class="QScrollArea" name="scrollArea"><property name="widgetResizable"><bool>true</bool></property><widget class="QWidget" name="scrollAreaWidgetContents"><property name="geometry"><rect><x>0</x><y>0</y><width>398</width><height>252</height></rect></property><layout class="QHBoxLayout" name="horizontalLayout"><item><layout class="QVBoxLayout" name="VLX"><item><widget class="QLineEdit" name="LEX1"><property name="text"><string/></property></widget></item><item><widget class="QLineEdit" name="LEX2"/></item></layout></item><item><layout class="QVBoxLayout" name="VLJ"><item><widget class="QLineEdit" name="LEJ1"/></item><item><widget class="QLineEdit" name="LEJ2"/></item></layout></item></layout><zorder></zorder><zorder></zorder></widget></widget></item></layout><zorder>label_2</zorder><zorder>label_3</zorder><zorder>pjjd</zorder><zorder>add</zorder><zorder>cal</zorder><zorder>label</zorder><zorder>scrollArea</zorder></widget><widget class="QMenuBar" name="menuBar"><property name="geometry"><rect><x>0</x><y>0</y><width>520</width><height>23</height></rect></property></widget><widget class="QToolBar" name="mainToolBar"><attribute name="toolBarArea"><enum>TopToolBarArea</enum></attribute><attribute name="toolBarBreak"><bool>false</bool></attribute></widget><widget class="QStatusBar" name="statusBar"/></widget><layoutdefault spacing="6" margin="11"/><resources><include location="icon.qrc"/></resources><connections/>
</ui>

main,cpp

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

用Qt写的平均绩点计算器相关推荐

  1. 大学平均绩点计算器_【采访合集】大一必知“绩点”与“奥方面试”

    绩点 对大学生来说,绩点是一个非常重要的指标,它代表着你在大学整个学习阶段.学习当中的课程水平. 绩点是评估学习成绩的一种方法,国内大部分高校通用的计算方法是:绩点=分数/10-5,学分绩点=学分*绩 ...

  2. GPA——平均绩点计算器(5.0分制)

    平均绩点通常指平均学分绩点(即GPA,Grade Point Average).某些学校采用学分绩点制对学生学习质量进行评定,平均学分绩点是主要考察指标. 本篇博客提供了C++语言编写的GPA计算器, ...

  3. 大学平均绩点计算器_申请韩国名校绩点是不是万能的?

    最近有很多学生来问,老师我的大学本科GPA 还算不错,那我是不是就可以申请 首尔,延世,高丽大学了? 或者说 老师我的本科成绩非常不好,那我是不是就没有机会申请韩国前20的学校了呢, 其实这个答案是不 ...

  4. 浙江工业大学简易绩点计算器c++版

    最近需要计算本学年的绩点,于是随手写了一个绩点计算器.适用于浙江工业大学.编译环境VS2010. #include<iostream> #include<string> #in ...

  5. python计算平均绩点_【python】以五分制绩点为基础的绩点计算器,可计算学分加权平均...

    [python]以五分制绩点为基础的绩点计算器,可计算学分加权平均 [python]以五分制绩点为基础的绩点计算器,可计算学分加权平均分和平均学分绩点 目录 一.以五分制绩点为基础的绩点计算器 1.1 ...

  6. 学生成绩平均绩点计算:绩点计算器(5.0分制,Java、C实现)

    计算规则: 分数 绩点 60-100 1.0-5.0 0-59 0 平均学分绩点=(∑(已修读课程绩点×课程学分))/(∑已修读课程学分): Java: package Test; //GpaCalc ...

  7. 广工计算机学院绩点,广工平均学分绩点计算器的教程

    完美者(wmzhe.com)网站以软件下载为基础,改版后的网站对功能性板块进行扩充,以期能够解决用户在软件使用过程中遇见的所有问题.网站新增了"软件百科"."锦囊妙技&q ...

  8. 5分绩点转4分_5分制绩点计算器: 由于网上的绩点工具大多都是4分制的,而自己一门一门的计算绩点又非常麻烦,所以我就写了一个快速计算绩点的教程。...

    前言 由于网上的绩点工具大多都是4分制的,而自己一门一门的计算绩点又非常麻烦,所以我就写了一个快速计算绩点的教程.本人写了两个版本的计算器,分别是成绩版和绩点版,区别在于前者输入的内容是每门学科的学分 ...

  9. 杭电计算机学院绩点,杭电平均成绩绩点计算器的教程

    完美者(wmzhe.com)网站以软件下载为基础,改版后的网站对功能性板块进行扩充,以期能够解决用户在软件使用过程中遇见的所有问题.网站新增了"软件百科"."锦囊妙技&q ...

最新文章

  1. Vue中添加新的路由并访问
  2. 无线节能组的充电问题
  3. 一起学nRF51xx 7 -  spi
  4. 【ACM】会场安排问题
  5. 公众平台模板消息所在行业_微信公众号模板消息功能怎么快速推送?
  6. linux之让终端支持C++11/14编译cpp文件
  7. linux 0.11 源码学习(二)
  8. 数据分析中会常犯哪些错误,如何解决? 三
  9. 幼儿园计算机课程心得,幼儿主题式课程教学心得体会
  10. php家族族谱代码,家族族谱系统设计.doc
  11. OneNote使用技巧 - 5.快速设置首行缩进
  12. pd安装win10错误-安全启动功能发现未经授权更改固件
  13. 中小学直播活动如何选择编码器还是直播机?
  14. java翁恺MOOC每周编程题
  15. 弹窗广告避无可避,背后黑手如此投放!
  16. 【C#】使用CefSharp实现淘宝接口限制下的自动滑块
  17. 颗粒离散元软件(PFC)中Python第三方cartopy包配置
  18. 零打碎敲学Android(三)—俄罗斯,你为什么是方块的?
  19. DR平板探测器常识——非晶硒和非晶硅平板探测器的区别
  20. 云安虚拟化应用性能监测系统为数据中心整合新的潮流

热门文章

  1. Vision Transformer(iGPT,ViT,DERT,IPT,TransReID,TransGAN,TNT,CvT)
  2. 微信小程序上划加载下划刷新
  3. html5游戏发行,UC游戏成国内最大HTML5游戏发行平台
  4. 2018中国区块链百强企业第二弹 | 链塔智库
  5. 在angular中,我有一个路由'/sdfsd/sss/ss',实现在一函数,判断路由配置对象中是否存在该路由...
  6. Android实现简易示波器
  7. Python数据可视化 Pyecharts 制作 Line3D 3D折线图
  8. java gif jpg_Java gif图片转换为jpg格式
  9. VS中使用QT,多国语言翻译问题
  10. AD7606调试笔记:采集多路不正常,少采集几路就正常