Skip to content

Commit

Permalink
完成实时金额,修改布局__ Debug需要把Build设置为Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wxydejoy committed Apr 9, 2023
1 parent 2d46d1f commit cd202c3
Show file tree
Hide file tree
Showing 3 changed files with 311 additions and 246 deletions.
2 changes: 1 addition & 1 deletion message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ message::message(QWidget *parent) :

void message::update(int progress,float money){
//更新进度条
ui->labelMoney->setText("预计今日一共挣"+QString::number(money,'f',1)+"");
ui->labelMoney->setText("您当前已经挣了"+QString::number(money*progress/1000,'f',1)+"");
ui->progressBar->setValue(progress);

}
Expand Down
29 changes: 17 additions & 12 deletions moneyprogress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,28 @@ void MoneyProgress::update()
qDebug("update");
int second = (workUp.secsTo(workDown) - sleepUp.secsTo(sleepDown));
float hours = second / 3600.0;

int progress = 0;
float moneyday = money / days;
float moneysecond = moneyday / second;

if (QTime::currentTime() < sleepUp) //判断当前使是午休之前还是之后
progress = workUp.secsTo(QTime::currentTime()) * 1000 / second;
else
progress = (workUp.secsTo(QTime::currentTime()) - sleepUp.secsTo(sleepDown)) * 1000 / second;

// 判断两个界面是否可见
if (this->isVisible())
{
ui->labelMoneyNow->setText("您当前已经挣了"+QString::number(moneyday*progress/1000,'f',1)+"元;");
ui->labelDay->setText("您一月工作" + QString::number(days) + "天;");
ui->labelMoneyDay->setText("您一天能挣" + QString::number(moneyday, 'f', 1) + "元;");
ui->labelHourDay->setText("您一天工作" + QString::number(hours, 'f', 1) + "小时;");
ui->labelMoneySecond->setText("您一秒钟能挣" + QString::number(moneysecond, 'f', 6) + "元;");
}
if (iconmessage.isVisible())
{
int progress = 0;
if (QTime::currentTime() < sleepUp)
progress = workUp.secsTo(QTime::currentTime()) * 1000 / second;
else
progress = (workUp.secsTo(QTime::currentTime()) - sleepUp.secsTo(sleepDown)) * 1000 / second;


iconmessage.update(progress, moneyday);
qDebug() << progress;
}
Expand All @@ -212,17 +216,18 @@ void MoneyProgress::updateM()

float moneyday = money / days;
float moneysecond = moneyday / second;
// 判断两个界面是否可见

ui->labelDay->setText("您一月工作" + QString::number(days) + "天;");
ui->labelMoneyDay->setText("您一天能挣" + QString::number(moneyday, 'f', 1) + "元;");
ui->labelHourDay->setText("您一天工作" + QString::number(hours, 'f', 1) + "小时;");
ui->labelMoneySecond->setText("您一秒钟能挣" + QString::number(moneysecond, 'f', 6) + "元;");
int progress = 0;
if (QTime::currentTime() < sleepUp)
progress = workUp.secsTo(QTime::currentTime()) * 1000 / second;
else
progress = (workUp.secsTo(QTime::currentTime()) - sleepUp.secsTo(sleepDown)) * 1000 / second;
// 判断两个界面是否可见
ui->labelMoneyNow->setText("您当前已经挣了"+QString::number(moneyday*progress/1000,'f',1)+"元;");
ui->labelDay->setText("您一月工作" + QString::number(days) + "天;");
ui->labelMoneyDay->setText("您一天能挣" + QString::number(moneyday, 'f', 1) + "元;");
ui->labelHourDay->setText("您一天工作" + QString::number(hours, 'f', 1) + "小时;");
ui->labelMoneySecond->setText("您一秒钟能挣" + QString::number(moneysecond, 'f', 6) + "元;");

qDebug() << progress;
iconmessage.update(progress, moneyday);
}
Expand Down
Loading

0 comments on commit cd202c3

Please sign in to comment.