代码拉取完成,页面将自动刷新
#include "widget.h"
#include "ui_widget.h"
#include "QString"
#include "iostream"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
int adDamage = 0;
int apDamage = 0;
void Widget::on_adInfoAddButton_clicked()
{
bool isSuccess;
QString valueText = ui->adInfoAdd->text();
int value = valueText.toInt(&isSuccess);
if(isSuccess) {
adDamage += value;
QString qS = "ad伤害:";
qS.append(valueText);
ui->listWidget->addItem(qS);
ui->adInfoAdd->setText("");
}
}
void Widget::on_adInfoAdd_textEdited(const QString &arg1)
{
bool isSuccess;
int value = arg1.toInt(&isSuccess);
if(!isSuccess) {
ui->adInfoAdd->setText(arg1.left(arg1.length() - 1));
}
}
void Widget::on_apInfoAddButton_clicked()
{
bool isSuccess;
QString valueText = ui->apInfoAdd->text();
int value = valueText.toInt(&isSuccess);
if(isSuccess) {
apDamage += value;
QString qS = "ap伤害:";
qS.append(valueText);
ui->listWidget->addItem(qS);
ui->apInfoAdd->setText("");
}
}
void Widget::on_apInfoAdd_textEdited(const QString &arg1)
{
bool isSuccess;
int value = arg1.toInt(&isSuccess);
if(!isSuccess) {
ui->adInfoAdd->setText(arg1.left(arg1.length() - 1));
}
}
void Widget::on_adInfoAdd_returnPressed()
{
bool isSuccess;
QString valueText = ui->adInfoAdd->text();
int value = valueText.toInt(&isSuccess);
if(isSuccess) {
adDamage += value;
QString qS = "ad伤害:";
qS.append(valueText);
ui->listWidget->addItem(qS);
ui->adInfoAdd->setText("");
}
}
void Widget::on_apInfoAdd_returnPressed()
{
bool isSuccess;
QString valueText = ui->apInfoAdd->text();
int value = valueText.toInt(&isSuccess);
if(isSuccess) {
apDamage += value;
QString qS = "ap伤害:";
qS.append(valueText);
ui->listWidget->addItem(qS);
ui->apInfoAdd->setText("");
}
}
void Widget::on_startCalculate_clicked()
{
int total = 0;
int armor = ui->armorInfoAdd->text().toInt();
int adFinal = adDamage * armor / (100 + armor);
int magicResist = ui->MagicResistAdd->text().toInt();
int apFinal = apDamage * magicResist / (100 + armor);
ui->damageInfo->setText(QString::number(adFinal + apFinal));
// int apFinal = apDamage *
}
void Widget::on_listWidget_doubleClicked(const QModelIndex &index)
{
QListWidgetItem *item = ui->listWidget->takeItem(index.column());
if(item->text().contains("ap")) {
QString value = item->text().replace("ap伤害:","");
int temp = value.toInt();
apDamage -= temp;
} else {
QString value = item->text().replace("ad伤害:","");
int temp = value.toInt();
adDamage -= temp;
}
delete item;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。