UI展示
项目思路
- 采用stacked_widget制作不同贷款类型的界面和组件
- 当用户点击计算按钮时,首先获取用户输入的各种数值
- 根据公式计算利息和月供
- 在结果页面显示
代码
头文件
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_main_widgets.h"
class QStackedWidget;
class main_widgets : public QMainWindow
{
Q_OBJECT
public:
main_widgets(QWidget *parent = nullptr);
~main_widgets();
// 显示商业贷款页面
void setPageWidgetCommercial();
// 显示公积金贷款页面
void setPageWidgetFund();
// 显示组合贷款页面
void setPageWidgetPortfolio();
// 显示计算结果页面
void setPageWidgetResult();
// 显示帮助页面
void setPageWidgetHelp();
// 房贷期限列表
QStringList m_strList;
// 贷款方式
unsigned char m_sMortgageType;
// 期次,最多30 * 12 == 360期
unsigned short m_sMonthCounter;
// 贷款本金,单位:万元
float m_fPrincipalCom;
float m_fPrincipalFun;
// 利率,不能为负值
float m_fInterestRateCom;
float m_fInterestRateFun;
// 每月利率
float m_fInterestRatePerMonthCom;
float m_fInterestRatePerMonthFun;
// 利息总额
float m_fInterestSum;
float m_fInterestSumChanged;
QString m_strInterestSum;
// 累计还款总额
float m_fMortgageSum;
float m_fMortgageSumChanged;
QString m_strMortgageSum;
// 每月月供
float m_fMortgagePerMonth;
QString m_strMortgagePerMonth;
// 首月月供
float m_fMortgageFirstMonth;
QString m_strMortgageFirstMonth;
// 末月月供
float m_fMortgageLastMonth;
QString m_strMortgageLastMonth;
// 最高月付利息
float m_fHigestInterest;
QString m_strHigestInterest;
// 等额本息复选框的状态
bool m_bCheckBoxPI;
// 等额本金复选框的状态
bool m_bCheckBoxP;
private:
Ui::main_widgetsClass ui;
public slots:
// 响应“商业贷款计算”按钮的槽函数
void onPushButtonClickedCom();
// 响应“公积金贷款计算”按钮的槽函数
void onPushButtonClickedFun();
// 响应“组合贷款计算”按钮的槽函数
void onPushButtonClickedPor();
// 响应“返回商业贷款”按钮的槽函数
void onPushButtonClickedRetCom();
// 响应“返回公积金贷款”按钮的槽函数
void onPushButtonClickedRetFun();
// 响应帮助菜单的槽函数
void onPushButtonClickedHelp();
// 响应“返回组合贷款”按钮的槽函数
void onPushButtonClickedRetPor();
// 响应商业贷款“等额本息”的复选框
void onCheckBoxClickedPICom();
// 响应商业贷款“等额本金”的复选框
void onCheckBoxClickedPCom();
// 响应公积金贷款“等额本息”的复选框
void onCheckBoxClickedPIFun();
// 响应公积金贷款“等额本金”的复选框
void onCheckBoxClickedPFun();
// 响应组合贷款“等额本息”的复选框
void onCheckBoxClickedPIPor();
// 响应组合贷款“等额本金”的复选框
void onCheckBoxClickedPPor();
};
源文件
#include "main_widgets.h"
#include <qdebug.h>
#include <qmath.h>
#include <qstackedwidget.h>
#include <qaction.h>
main_widgets::main_widgets(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
// 界面公用数据
// 默认显示商业贷款界面
ui.stackedWidget->setCurrentIndex(0);
// 连接商业贷款菜单与界面
connect(ui.menuCommercial, SIGNAL(aboutToShow()), this, SLOT(onPushButtonClickedRetCom()));
// 连接公积金贷款菜单与界面
connect(ui.menuFund, SIGNAL(aboutToShow()), this, SLOT(onPushButtonClickedRetFun()));
// 连接组合贷款菜单与界面
connect(ui.menuPortfolio, SIGNAL(aboutToShow()), this, SLOT(onPushButtonClickedRetPor()));
// 连接帮助菜单与界面
connect(ui.menuHelp, SIGNAL(aboutToShow()), this, SLOT(onPushButtonClickedHelp()));
// 初始化三个界面的下拉框
m_strList << "半年(6期)";
for (int index = 1; index < 31; index++)
{
QString strIndex = QString::number(index);
QString strIndexYears = QString::number(12*index);
QString strMonth = strIndex + "年(" + strIndexYears + ")期";
m_strList << strMonth;
}
ui.comboBoxCom->addItems(m_strList);
ui.comboBoxFun->addItems(m_strList);
ui.comboBoxPor->addItems(m_strList);
ui.comboBoxCom->setCurrentIndex(30);
ui.comboBoxFun->setCurrentIndex(30);
ui.comboBoxPor->setCurrentIndex(30);
// 计算按钮
ui.pushButtonComCal->setCheckable(true);
connect(ui.pushButtonComCal, SIGNAL(clicked()), this, SLOT(onPushButtonClickedCom()));
ui.pushButtonFunCal->setCheckable(true);
connect(ui.pushButtonFunCal, SIGNAL(clicked()), this, SLOT(onPushButtonClickedFun()));
ui.pushButtonPorCal->setCheckable(true);
connect(ui.pushButtonPorCal, SIGNAL(clicked()), this, SLOT(onPushButtonClickedPor()));
// 返回按钮
connect(ui.pushButtonRetCom, SIGNAL(clicked()), this, SLOT(onPushButtonClickedRetCom()));
connect(ui.pushButtonRetFun, SIGNAL(clicked()), this, SLOT(onPushButtonClickedRetFun()));
connect(ui.pushButtonRetPor, SIGNAL(clicked()), this, SLOT(onPushButtonClickedRetPor()));
// 默认设置等额本息
ui.checkBoxPICom->setChecked(true);
ui.checkBoxPIFun->setChecked(true);
ui.checkBoxPIPor->setChecked(true);
// 点击商业贷款等额本息复选框
connect(ui.checkBoxPICom, SIGNAL(clicked()), this, SLOT(onCheckBoxClickedPICom()));
// 点击商业贷款等额本金复选框
connect(ui.checkBoxPCom, SIGNAL(clicked()), this, SLOT(onCheckBoxClickedPCom()));
// 点击公积金贷款等额本息复选框
connect(ui.checkBoxPIFun, SIGNAL(clicked()), this, SLOT(onCheckBoxClickedPIFun()));
// 点击公积金贷款等额本金复选框
connect(ui.checkBoxPFun, SIGNAL(clicked()), this, SLOT(onCheckBoxClickedPFun()));
// 点击组合贷款等额本息复选框
connect(ui.checkBoxPIPor, SIGNAL(clicked()), this, SLOT(onCheckBoxClickedPIPor()));
// 点击组合贷款等额本金复选框
connect(ui.checkBoxPPor, SIGNAL(clicked()), this, SLOT(onCheckBoxClickedPPor()));
// 贷款方式
m_sMortgageType = 2;
// 期次,最多30 * 12 == 360期
m_sMonthCounter = 360;
// 贷款本金,单位:万元
m_fPrincipalCom = 100;
m_fPrincipalFun = 50;
// 利率,不能为负值
m_fInterestRateCom = 4.30;
m_fInterestRateFun = 3.25;
// 每月利率
m_fInterestRatePerMonthCom = 4.30 / 12 / 100;
m_fInterestRatePerMonthFun = 3.25 / 12 / 100;
// 利息总额
m_fInterestSum = 0;
m_fInterestSumChanged = 0;
m_strInterestSum = "";
// 累计还款总额
m_fMortgageSum = 0;
m_fMortgageSumChanged = 0;
m_strMortgageSum = "";
// 每月月供
m_fMortgagePerMonth = 0;
m_strMortgagePerMonth = "";
// 首月月供
m_fMortgageFirstMonth = 0;
m_strMortgageFirstMonth = "";
// 末月月供
m_fMortgageLastMonth = 0;
m_strMortgageLastMonth = "";
// 最高月付利息
m_fHigestInterest = 0;
m_strHigestInterest = "";
// 等额本息复选框的状态
m_bCheckBoxPI = true;
// 等额本金复选框的状态
m_bCheckBoxP = false;
}
main_widgets::~main_widgets()
{
}
/********************************************************************************
* FunctionName :
*********************************************************************************
* Abstract : 响应“商业贷款计算”按钮的槽函数
* Argument1(in) :
* Argument2(out) :
* Return Value :
* Remarks :
* Create :
* History :
********************************************************************************/
void main_widgets::onPushButtonClickedCom()
{
// 本金,从line_edit读取的是string类型,先转换成float类型
// 注意本金单位是万元!
m_fPrincipalCom = (ui.lineEditPrin->text()).toFloat();
if (m_fPrincipalCom <= 0)
{
ui.lineEditPrin->setText("请输入大于0的数");
return;
}
m_fPrincipalCom = 10000 * m_fPrincipalCom;
// qDebug() << m_fPrincipal;
// 年利率,从line_edit读取的是string类型,先转换成float类型
// 注意年利率单位是%,先转换成小数再除于12
m_fInterestRateCom = (ui.lineEditRate->text()).toFloat();
if (m_fInterestRateCom <= 0)
{
ui.lineEditRate->setText("请输入大于0的数");
return;
}
m_fInterestRatePerMonthCom = m_fInterestRateCom / 100 / 12;
// qDebug() << m_fInterestRatePerMonth;
// 贷款方式
if (ui.checkBoxPICom->isChecked())
{
if (ui.checkBoxPCom->isChecked())
{
m_sMortgageType = 3;
return;
}
else
{
m_sMortgageType = 2;
}
}
else
{
if (ui.checkBoxPCom->isChecked())
{
m_sMortgageType = 1;
}
else
{
m_sMortgageType = 0;
ui.checkBoxPICom->setChecked(true);
return;
}
}
// 期次
if (ui.comboBoxCom->currentIndex() == 0)
{
m_sMonthCounter = 6;
}
else
{
m_sMonthCounter = 12 * (ui.comboBoxCom->currentIndex());
}
// 等额本息
if (m_sMortgageType == 2)
{
// 每月偿还本息,复利计算
float m_fTemp = qPow((1 + m_fInterestRatePerMonthCom), m_sMonthCounter);
m_fMortgagePerMonth = (m_fPrincipalCom * m_fInterestRatePerMonthCom * m_fTemp) / (m_fTemp - 1);
// qDebug() << m_fTemp;
// qDebug() << (m_fPrincipal * m_fInterestRatePerMonth * m_fTemp);
// qDebug() << (m_fTemp - 1);
// qDebug() << m_sMonthCounter;
// qDebug() << m_fMortgagePerMonth;
m_strMortgagePerMonth = QString("%1").arg(m_fMortgagePerMonth);
ui.labelAverage->setText(m_strMortgagePerMonth);
// 还款本息总额
m_fMortgageSum = m_fMortgagePerMonth * m_sMonthCounter;
m_fMortgageSumChanged = m_fMortgageSum / 10000;
m_strMortgageSum = QString("%1").arg(m_fMortgageSumChanged);
ui.labelPISum->setText(m_strMortgageSum);
// 利息总额
m_fInterestSum = m_fMortgageSum - m_fPrincipalCom;
m_fInterestSumChanged = m_fInterestSum / 10000;
m_strInterestSum = QString("%1").arg(m_fInterestSumChanged);
ui.labelInterestSum->setText(m_strInterestSum);
// 首月月供
ui.labelFirstMonth->setText(m_strMortgagePerMonth);
// 末月月供
ui.labelLastMonth->setText(m_strMortgagePerMonth);
// 最高月付利息
m_fHigestInterest = m_fMortgagePerMonth - ((m_fPrincipalCom * m_fInterestRatePerMonthCom) / (m_fTemp - 1));
m_strHigestInterest = QString("%1").arg(m_fHigestInterest);
ui.labelHigthestInterest->setText(m_strHigestInterest);
setPageWidgetResult();
}
// 等额本金
else if (m_sMortgageType == 1)
{
// 还款本息总额
m_fMortgageSum = m_fPrincipalCom * (m_sMonthCounter * m_fInterestRatePerMonthCom + m_fInterestRatePerMonthCom + 2) / 2;
m_fMortgageSumChanged = m_fMortgageSum / 10000;
m_strMortgageSum = QString("%1").arg(m_fMortgageSumChanged);
ui.labelPISum->setText(m_strMortgageSum);
// 利息总额
m_fInterestSum = m_fMortgageSum - m_fPrincipalCom;
m_fInterestSumChanged = m_fInterestSum / 10000;
m_strInterestSum = QString("%1").arg(m_fInterestSumChanged);
ui.labelInterestSum->setText(m_strInterestSum);
// 平均每月偿还本息
m_fMortgagePerMonth = m_fMortgageSum / m_sMonthCounter;
m_strMortgagePerMonth = QString("%1").arg(m_fMortgagePerMonth);
ui.labelAverage->setText(m_strMortgagePerMonth);
// 首月月供
m_fMortgageFirstMonth = (m_fPrincipalCom / m_sMonthCounter) + (m_fPrincipalCom * m_fInterestRatePerMonthCom);
m_strMortgageFirstMonth = QString("%1").arg(m_fMortgageFirstMonth);
ui.labelFirstMonth->setText(m_strMortgageFirstMonth);
// 末月月供
m_fMortgageLastMonth = (m_fPrincipalCom / m_sMonthCounter) * (1 + m_fInterestRatePerMonthCom);
m_strMortgageLastMonth = QString("%1").arg(m_fMortgageLastMonth);
ui.labelLastMonth->setText(m_strMortgageLastMonth);
// 最高月付利息
m_fHigestInterest = m_fPrincipalCom * m_fInterestRatePerMonthCom;
m_strHigestInterest = QString("%1").arg(m_fHigestInterest);
ui.labelHigthestInterest->setText(m_strHigestInterest);
setPageWidgetResult();
}
}
// 响应“公积金贷款计算”按钮的槽函数
void main_widgets::onPushButtonClickedFun()
{
// 本金,从line_edit读取的是string类型,先转换成float类型
// 注意本金单位是万元!
m_fPrincipalFun= (ui.lineEditPrinFun->text()).toFloat();
if (m_fPrincipalFun <= 0)
{
ui.lineEditPrinFun->setText("请输入大于0的数");
return;
}
m_fPrincipalFun = 10000 * m_fPrincipalFun;
// qDebug() << m_fPrincipal;
// 年利率,从line_edit读取的是string类型,先转换成float类型
// 注意年利率单位是%,先转换成小数再除于12
m_fInterestRateFun = (ui.lineEditRateFun->text()).toFloat();
if (m_fInterestRateFun <= 0)
{
ui.lineEditRateFun->setText("请输入大于0的数");
return;
}
m_fInterestRatePerMonthFun = m_fInterestRateFun / 100 / 12;
// 贷款方式
if (ui.checkBoxPIFun->isChecked())
{
if (ui.checkBoxPFun->isChecked())
{
m_sMortgageType = 3;
return;
}
else
{
m_sMortgageType = 2;
}
}
else
{
if (ui.checkBoxPFun->isChecked())
{
m_sMortgageType = 1;
}
else
{
m_sMortgageType = 0;
ui.checkBoxPIFun->setChecked(true);
return;
}
}
// 期次
if (ui.comboBoxFun->currentIndex() == 0)
{
m_sMonthCounter = 6;
}
else
{
m_sMonthCounter = 12 * (ui.comboBoxFun->currentIndex());
}
// 等额本息
if (m_sMortgageType == 2)
{
// 每月偿还本息,复利计算
float m_fTemp = qPow((1 + m_fInterestRatePerMonthFun), m_sMonthCounter);
m_fMortgagePerMonth = (m_fPrincipalFun * m_fInterestRatePerMonthFun * m_fTemp) / (m_fTemp - 1);
m_strMortgagePerMonth = QString("%1").arg(m_fMortgagePerMonth);
ui.labelAverage->setText(m_strMortgagePerMonth);
// 还款本息总额
m_fMortgageSum = m_fMortgagePerMonth * m_sMonthCounter;
m_fMortgageSumChanged = m_fMortgageSum / 10000;
m_strMortgageSum = QString("%1").arg(m_fMortgageSumChanged);
ui.labelPISum->setText(m_strMortgageSum);
// 利息总额
m_fInterestSum = m_fMortgageSum - m_fPrincipalFun;
m_fInterestSumChanged = m_fInterestSum / 10000;
m_strInterestSum = QString("%1").arg(m_fInterestSumChanged);
ui.labelInterestSum->setText(m_strInterestSum);
// 首月月供
ui.labelFirstMonth->setText(m_strMortgagePerMonth);
// 末月月供
ui.labelLastMonth->setText(m_strMortgagePerMonth);
// 最高月付利息
m_fHigestInterest = m_fMortgagePerMonth - ((m_fPrincipalFun * m_fInterestRatePerMonthFun) / (m_fTemp - 1));
m_strHigestInterest = QString("%1").arg(m_fHigestInterest);
ui.labelHigthestInterest->setText(m_strHigestInterest);
setPageWidgetResult();
}
// 等额本金
else if (m_sMortgageType == 1)
{
// 还款本息总额
m_fMortgageSum = m_fPrincipalFun * (m_sMonthCounter * m_fInterestRatePerMonthFun + m_fInterestRatePerMonthFun + 2) / 2;
m_fMortgageSumChanged = m_fMortgageSum / 10000;
m_strMortgageSum = QString("%1").arg(m_fMortgageSumChanged);
ui.labelPISum->setText(m_strMortgageSum);
// 利息总额
m_fInterestSum = m_fMortgageSum - m_fPrincipalFun;
m_fInterestSumChanged = m_fInterestSum / 10000;
m_strInterestSum = QString("%1").arg(m_fInterestSumChanged);
ui.labelInterestSum->setText(m_strInterestSum);
// 平均每月偿还本息
m_fMortgagePerMonth = m_fMortgageSum / m_sMonthCounter;
m_strMortgagePerMonth = QString("%1").arg(m_fMortgagePerMonth);
ui.labelAverage->setText(m_strMortgagePerMonth);
// 首月月供
m_fMortgageFirstMonth = (m_fPrincipalCom / m_sMonthCounter) + (m_fPrincipalFun * m_fInterestRatePerMonthFun);
m_strMortgageFirstMonth = QString("%1").arg(m_fMortgageFirstMonth);
ui.labelFirstMonth->setText(m_strMortgageFirstMonth);
// 末月月供
m_fMortgageLastMonth = (m_fPrincipalFun / m_sMonthCounter) * (1 + m_fInterestRatePerMonthFun);
m_strMortgageLastMonth = QString("%1").arg(m_fMortgageLastMonth);
ui.labelLastMonth->setText(m_strMortgageLastMonth);
// 最高月付利息
m_fHigestInterest = m_fPrincipalFun * m_fInterestRatePerMonthFun;
m_strHigestInterest = QString("%1").arg(m_fHigestInterest);
ui.labelHigthestInterest->setText(m_strHigestInterest);
setPageWidgetResult();
}
}
// 响应“组合贷款计算”按钮的槽函数
void main_widgets::onPushButtonClickedPor()
{
// 本金,从line_edit读取的是string类型,先转换成float类型
// 注意本金单位是万元!
m_fPrincipalCom = (ui.lineEditComPrinPor->text()).toFloat();
if (m_fPrincipalCom <= 0)
{
ui.lineEditComPrinPor->setText("请输入大于0的数");
return;
}
m_fPrincipalCom = 10000 * m_fPrincipalCom;
m_fPrincipalFun = (ui.lineEditFunPrinPor->text()).toFloat();
if (m_fPrincipalFun <= 0)
{
ui.lineEditFunPrinPor->setText("请输入大于0的数");
return;
}
m_fPrincipalFun = 10000 * m_fPrincipalFun;
// 年利率,从line_edit读取的是string类型,先转换成float类型
// 注意年利率单位是%,先转换成小数再除于12
m_fInterestRateCom = (ui.lineEditComRatePor->text()).toFloat();
if (m_fInterestRateCom <= 0)
{
ui.lineEditComRatePor->setText("请输入大于0的数");
return;
}
m_fInterestRatePerMonthCom = m_fInterestRateCom / 100 / 12;
m_fInterestRateFun = (ui.lineEditFunRatePor->text()).toFloat();
if (m_fInterestRateFun <= 0)
{
ui.lineEditFunRatePor->setText("请输入大于0的数");
return;
}
m_fInterestRatePerMonthFun = m_fInterestRateFun / 100 / 12;
// 贷款方式
if (ui.checkBoxPIPor->isChecked())
{
if (ui.checkBoxPPor->isChecked())
{
m_sMortgageType = 3;
return;
}
else
{
m_sMortgageType = 2;
}
}
else
{
if (ui.checkBoxPPor->isChecked())
{
m_sMortgageType = 1;
}
else
{
m_sMortgageType = 0;
ui.checkBoxPIPor->setChecked(true);
return;
}
}
// 期次
if (ui.comboBoxCom->currentIndex() == 0)
{
m_sMonthCounter = 6;
}
else
{
m_sMonthCounter = 12 * (ui.comboBoxCom->currentIndex());
}
// 等额本息
if (m_sMortgageType == 2)
{
// 每月偿还本息,复利计算
float m_fTemp0 = qPow((1 + m_fInterestRatePerMonthCom), m_sMonthCounter);
float m_fMortgagePerMonthCom = (m_fPrincipalCom * m_fInterestRatePerMonthCom * m_fTemp0) / (m_fTemp0 - 1);
float m_fTemp1 = qPow((1 + m_fInterestRatePerMonthFun), m_sMonthCounter);
float m_fMortgagePerMonthFun = (m_fPrincipalFun * m_fInterestRatePerMonthFun * m_fTemp1) / (m_fTemp1 - 1);
m_fMortgagePerMonth = m_fMortgagePerMonthCom + m_fMortgagePerMonthFun;
m_strMortgagePerMonth = QString("%1").arg(m_fMortgagePerMonth);
ui.labelAverage->setText(m_strMortgagePerMonth);
// 还款本息总额
m_fMortgageSum = m_fMortgagePerMonth * m_sMonthCounter;
m_fMortgageSumChanged = m_fMortgageSum / 10000;
m_strMortgageSum = QString("%1").arg(m_fMortgageSumChanged);
ui.labelPISum->setText(m_strMortgageSum);
// 利息总额
m_fInterestSum = m_fMortgageSum - m_fPrincipalCom - m_fPrincipalFun;
m_fInterestSumChanged = m_fInterestSum / 10000;
m_strInterestSum = QString("%1").arg(m_fInterestSumChanged);
ui.labelInterestSum->setText(m_strInterestSum);
// 首月月供
ui.labelFirstMonth->setText(m_strMortgagePerMonth);
// 末月月供
ui.labelLastMonth->setText(m_strMortgagePerMonth);
// 最高月付利息
float m_fHigestInterestCom = m_fMortgagePerMonthCom - ((m_fPrincipalCom * m_fInterestRatePerMonthCom) / (m_fTemp0 - 1));
float m_fHigestInterestFun = m_fMortgagePerMonthFun - ((m_fPrincipalFun * m_fInterestRatePerMonthFun) / (m_fTemp1 - 1));
m_fHigestInterest = m_fHigestInterestCom + m_fHigestInterestFun;
m_strHigestInterest = QString("%1").arg(m_fHigestInterest);
ui.labelHigthestInterest->setText(m_strHigestInterest);
setPageWidgetResult();
}
// 等额本金
else if (m_sMortgageType == 1)
{
// 还款本息总额
float m_fMortgageSumCom = m_fPrincipalCom * (m_sMonthCounter * m_fInterestRatePerMonthCom + m_fInterestRatePerMonthCom + 2) / 2;
float m_fMortgageSumFun = m_fPrincipalFun * (m_sMonthCounter * m_fInterestRatePerMonthFun + m_fInterestRatePerMonthFun + 2) / 2;
m_fMortgageSum = m_fMortgageSumCom + m_fMortgageSumFun;
m_fMortgageSumChanged = m_fMortgageSum / 10000;
m_strMortgageSum = QString("%1").arg(m_fMortgageSumChanged);
ui.labelPISum->setText(m_strMortgageSum);
// 利息总额
float m_fInterestSumCom = m_fMortgageSumCom - m_fPrincipalCom;
float m_fInterestSumFun = m_fMortgageSumFun - m_fPrincipalFun;
m_fInterestSum = m_fInterestSumCom + m_fInterestSumFun;
m_fInterestSumChanged = m_fInterestSum / 10000;
m_strInterestSum = QString("%1").arg(m_fInterestSumChanged);
ui.labelInterestSum->setText(m_strInterestSum);
// 平均每月偿还本息
m_fMortgagePerMonth = m_fMortgageSum / m_sMonthCounter;
m_strMortgagePerMonth = QString("%1").arg(m_fMortgagePerMonth);
ui.labelAverage->setText(m_strMortgagePerMonth);
// 首月月供
float m_fMortgageFirstMonthCom = (m_fPrincipalCom / m_sMonthCounter) + (m_fPrincipalCom * m_fInterestRatePerMonthCom);
float m_fMortgageFirstMonthFun = (m_fPrincipalFun / m_sMonthCounter) + (m_fPrincipalFun * m_fInterestRatePerMonthFun);
m_fMortgageFirstMonth = m_fMortgageFirstMonthCom + m_fMortgageFirstMonthFun;
m_strMortgageFirstMonth = QString("%1").arg(m_fMortgageFirstMonth);
ui.labelFirstMonth->setText(m_strMortgageFirstMonth);
// 末月月供
float m_fMortgageLastMonthCom = (m_fPrincipalCom / m_sMonthCounter) * (1 + m_fInterestRatePerMonthCom);
float m_fMortgageLastMonthFun = (m_fPrincipalFun / m_sMonthCounter) * (1 + m_fInterestRatePerMonthFun);
m_fMortgageLastMonth = m_fMortgageLastMonthCom + m_fMortgageLastMonthFun;
m_strMortgageLastMonth = QString("%1").arg(m_fMortgageLastMonth);
ui.labelLastMonth->setText(m_strMortgageLastMonth);
// 最高月付利息
m_fHigestInterest = m_fPrincipalCom * m_fInterestRatePerMonthCom + m_fPrincipalFun * m_fInterestRatePerMonthFun;
m_strHigestInterest = QString("%1").arg(m_fHigestInterest);
ui.labelHigthestInterest->setText(m_strHigestInterest);
setPageWidgetResult();
}
}
// 响应商业贷款“等额本息”的复选框
void main_widgets::onCheckBoxClickedPICom()
{
m_bCheckBoxPI = ui.checkBoxPICom->isChecked();
if (m_bCheckBoxPI)
{
ui.checkBoxPCom->setChecked(false);
}
}
// 响应商业贷款“等额本金”的复选框
void main_widgets::onCheckBoxClickedPCom()
{
m_bCheckBoxP = ui.checkBoxPCom->isChecked();
if (m_bCheckBoxP)
{
ui.checkBoxPICom->setChecked(false);
}
}
// 响应公积金贷款“等额本息”的复选框
void main_widgets::onCheckBoxClickedPIFun()
{
m_bCheckBoxPI = ui.checkBoxPIFun->isChecked();
if (m_bCheckBoxPI)
{
ui.checkBoxPFun->setChecked(false);
}
}
// 响应公积金贷款“等额本金”的复选框
void main_widgets::onCheckBoxClickedPFun()
{
m_bCheckBoxP = ui.checkBoxPFun->isChecked();
if (m_bCheckBoxP)
{
ui.checkBoxPIFun->setChecked(false);
}
}
// 响应组合贷款“等额本息”的复选框
void main_widgets::onCheckBoxClickedPIPor()
{
m_bCheckBoxPI = ui.checkBoxPIPor->isChecked();
if (m_bCheckBoxPI)
{
ui.checkBoxPPor->setChecked(false);
}
}
// 响应组合贷款“等额本金”的复选框
void main_widgets::onCheckBoxClickedPPor()
{
m_bCheckBoxP = ui.checkBoxPPor->isChecked();
if (m_bCheckBoxP)
{
ui.checkBoxPIPor->setChecked(false);
}
}
// 显示商业贷款页面
void main_widgets::setPageWidgetCommercial()
{
ui.stackedWidget->setCurrentIndex(0);
}
// 显示公积金贷款页面
void main_widgets::setPageWidgetFund()
{
ui.stackedWidget->setCurrentIndex(1);
}
// 显示组合贷款页面
void main_widgets::setPageWidgetPortfolio()
{
ui.stackedWidget->setCurrentIndex(2);
}
// 显示计算结果页面
void main_widgets::setPageWidgetResult()
{
ui.stackedWidget->setCurrentIndex(3);
}
// 显示帮助页面
void main_widgets::setPageWidgetHelp()
{
ui.stackedWidget->setCurrentIndex(4);
}
// 响应“返回商业贷款”按钮的槽函数
void main_widgets::onPushButtonClickedRetCom()
{
setPageWidgetCommercial();
}
// 响应“返回公积金贷款”按钮的槽函数
void main_widgets::onPushButtonClickedRetFun()
{
setPageWidgetFund();
}
// 响应“返回组合贷款”按钮的槽函数
void main_widgets::onPushButtonClickedRetPor()
{
setPageWidgetPortfolio();
}
// 响应帮助菜单的槽函数
void main_widgets::onPushButtonClickedHelp()
{
setPageWidgetHelp();
}
答疑
微信:Z15195800288