QT如何实现将两个时间相加

本篇内容介绍了“QT如何实现将两个时间相加”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

标志位

首先介绍实现的这两个函数:
void setTreatmentEndtime();//系统时间+我设定的时间=总的需要时间
void setRinseTimeStartAndEnd(QString Val);//将分钟转换为标准时分格式,在相加

需要设置的标志位:

//mainwindow.h
private://======================【SJY新增】
    uint8_t endtime_buttonflag;//剩余时间和结束时间切换标志位 【记得在构造函数初始化=0】
    QString Sys_time;//记录系统时间  【只要一次,所以需要设置标志位】
    QString MandatoryRinse;//记录强制冲洗时间 【只要一次需要设置标志位】

系统时间+设定的时间【源码附上】

QT如何实现将两个时间相加  qt 第1张

请看上图,在ui设计中往往需要显示系统时间和日期,而日期不可能禁止不动,需要实时刷新,这就不得不提出QT当中的定时器

第一步创建定时器并且开启

【1】在头文件添加日期时间头QDateTime
【2】toString的意思是将当前的日期时间转换为字符串,参数是时间格式
【3】在ui界面随便设置两个标签,将获取的字符串时间设置显示即可

//刷新时间【由定时器开启】 1s跑一次
void MainWindow::refresh_time()
{
    ui->label_date->setText(QDateTime::currentDateTime().toString("yyyy/MM/dd"));
    ui->label_time->setText(QDateTime::currentDateTime().toString("hh:mm:ss"));
}

上面的函数是由定时器开启的,具体如下:
【1】在mainwindow.h添加定时器的头文件QTime和对象 private: QTimer timer;
【2】将定时器对象通过connect函数形成信号与槽,信号发送函数timeout(); 槽接收函数refresh_time();
【3】&timer:对象地址【栈对象需要添加取址符&, 指针对象直接写名字,不需要&,本身就是地址】信号的发送者
【4】 timer.start(1000) :开启定时器,1s,也就是超过1s后会触发timeout()信号,start(参数是整形毫秒)
【5】timeout(): 信号发射函数,由定时器对象发射
【6】this:信号的接收者,this代码接收的是本类对象
【7】refresh_time(): 槽函数,由信号timeout触发,是本类对象的信心接收函数

//时间显示
    connect(&timer, SIGNAL(timeout()), this, SLOT(refresh_time()));
    timer.start(1000);//1s开启

第二步两个时间相加函数【已实现附上代码】

在多个MCU工作时,以下图片
第一个剩余时间:代表治疗某个病人,还需要多久
第二个结束时间:剩余结束时间+系统时间=医生几点可以下班【目的是为了直观显示】
系统时间已经在上面显示在ui了,对于label标签通过text()即可获取ui上的文本,系统时间获取;
剩余时间保存在一个数组,比如初始值=4:59

QT如何实现将两个时间相加  qt 第2张

//治疗剩余时间和结束时间的切换  【SJY新增】
void MainWindow::setTreatmentEndtime()
{
    if(endtime_buttonflag == 0){
        bool ok;
        uint32_t mm,hh;
        QStringList m1; QStringList m2;
        QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
        //QString time1_hm = data_lib->Get_Value(279);//保存在数组里
        QString time1_hm = ui->label_timeleft->text();//获取ui上的剩余时间
        QString time2_hm=ui->label_time->text();//获取ui上的系统时间
        m1 = time1_hm.split(":");//9:59
        m2 = time2_hm.split(":");//例如:23:59
        m3 = m1.at(0);//9
        m4 = m1.at(1);//59
        m5 = m2.at(0);//23
        m6 = m2.at(1);//59
        mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
        hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
        qDebug()<<m3<<m4<<m5<<m6<<hh<<mm<<endl;
        if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
        {
            if(mm == 60)//小时加1
            {
                m4 = QString("0");
                m3 = QString("0");
            }
            else//>60
            {
                    //小时加1  并且拼接出分钟数值
                if(( mm>=61) &&(mm<=69))//01-09
                {
                    m4 = QString("%1").arg(mm%60).at(0);//余数时5
                    m3 = QString("0");
                }
                else
                {
                    m4 = QString("%1").arg(mm%60).at(1);
                    m3 = QString("%1").arg(mm%60).at(0);
                }
            }
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt()+1);
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)//10-22
           {

              QString temp  = QString("%1").arg(hh%24);//19
              uint8_t  ret = temp.toInt()+1;//20  //11-23
              h3 = QString("%1").arg(ret).at(1);
               if(ret >= 20)
               {
                   h2 = QString("%1").arg(ret).at(0);
               }
               else
               {
                   h2 = QString("%1").arg(hh%24).at(0);
               }
           }
            else //<10
            {

                QString temp  = QString("%1").arg(hh%24);//=9
                uint8_t  ret = temp.toInt()+1;
                if(ret ==10)//10:00
                {
                         h2 = QString("1");
                         h3 = QString("0");
                }
                else {
                    h2 = QString("0");
                    h3 = QString("%1").arg(ret);
                }
            }
        }
        else if(mm >= 100)//大于等于100   mm最大时59+59=118
        {
            m4 = QString("%1").arg(mm%60).at(1);
            m3 = QString("%1").arg(mm%60).at(0);
            uint8_t rethh = mm/60;//转化为小时
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt()+rethh);
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {

               QString temp  = QString("%1").arg(hh%24);//=10
               uint8_t  ret = temp.toInt()+rethh;
               h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
            }
             else //<10
             {

                 QString temp  = QString("%1").arg(hh%24);//=9
                 uint8_t  ret = temp.toInt()+rethh;
                 if(ret ==10)//10:00
                 {
                          h2 = QString("1");
                          h3 = QString("0");
                 }
                 else {
                     h2 = QString("0");
                     h3 = QString("%1").arg(ret);
                 }
             }
        }
       else  if(mm<10 )
        {
            m4 = QString("%1").arg(mm%60);
            m3 = QString("%1").arg(0);
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt());
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {
                QString temp  = QString("%1").arg(hh%24);//=10
                uint8_t  ret = temp.toInt();
                h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
           }
            else //hh<10
            {
                uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                h2 = QString("0");
                h3 = QString("%1").arg(temp);
            }
        }
        else//     10<=mm>=59
        {
                m4 = QString(QString("%1").arg(mm%60).at(1));
                m3 = QString(QString("%1").arg(mm%60).at(0));

                //小时计算和求值
                if(hh >23)//半夜三更
                {
                    h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                    h2 = QString("0");
                }
                else if(hh == 23)//晚上:00.00
                {
                    h2 = QString("%1").arg(QString("0").toInt());
                    h3 = QString("0");
                }
                else if(hh>=10&&hh<=22)
               {
                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt();
                    h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
               }
                else //hh<10
                {
                    uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                    h2 = QString("0");
                    h3 = QString("%1").arg(temp);
                }
        }
            ui->label_endtime->setText(QString("%1%2:%3%4").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
            ui->label_26->hide();
            ui->label_timeleft->hide();
            ui->label_endtime->show();
            ui->label_timeend->show();
            endtime_buttonflag =1;
    }
    else if(endtime_buttonflag ==1){
            ui->label_26->show();
            ui->label_timeleft->show();
            ui->label_endtime->hide();
            ui->label_timeend->hide();
            endtime_buttonflag =0;
    }
}

第三步实现的效果截图
系统时间

QT如何实现将两个时间相加  qt 第3张

剩余时间

QT如何实现将两个时间相加  qt 第4张

【1】刚开始显示的是剩余时间,默认值,可通过按钮设置
【2】在这个时间背后我添加了一个原型按钮
【3】点击原型按钮可以切换剩余时间和结束时间【方便医护人员及时及时下班】

结束时间=剩余时间+系统时间

QT如何实现将两个时间相加  qt 第5张

【4】系统时间+清洗时间【附上源码】

【1】效果跟上面时一个道理,只是这里的清洗时间是分钟,范围是3-999,需要将清洗时间分钟转化为时分:hh:mm
【2】系统时间算法跟上面的一样 hh:mm
【3】想要的效果:
开始时间:hh:mm不变
结束时间=系统时间+清洗时间 hh:mm 跟随清洗时间的变化而变化
【4】清洗时间由控制MCU->发送通信给-》监控MCU->UI显示【实时变化】

第一步直接附上代码

//计算各个清洗按钮界面的开始时间和结束时间【SJY新增】
void MainWindow::setRinseTimeStartAndEnd(QString Val)
{
    if(Val == "水洗"){//3-999
            static uint8_t flag =0;
            if(flag == 0)//第一次进入
            {
                  Sys_time.clear();
                  Sys_time = ui->label_time->text();//获取系统时间
                  //qDebug()<<"Sys_time--------------------"<<Sys_time;
                  ui->label_Rinsestarttime->setText(tr(QString("开始时间 %1:%2").arg(Sys_time.split(":").at(0)).arg(Sys_time.split(":").at(1)).toUtf8().data()));
                  flag =1;//一直保留这个值
            }
             //QString Water_time = QString("0:%1").arg(ui->stage1_time_1->text().split(" ").at(0));//水洗时间分钟
            QString Water_time = QString("%1").arg(data_lib->Get_Value(71));//水洗时间分钟
            uint8_t hmus,min;
            uint32_t Total_time=Water_time.toInt();
            if(Total_time >59)
            {
                    Water_time.clear();
                    hmus = Total_time/60;//小时
                    min= Total_time%60;//分
                    Water_time = QString("%1:%2").arg(hmus).arg(min);
            }
            else
            {
                     Water_time.clear();
                     Water_time = QString("0:%1").arg(Total_time);
            }
             bool ok;
             uint32_t mm,hh;
             QStringList m1; QStringList m2;
             QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
             m1 = Water_time.split(":");//9:59
             m2 = Sys_time.split(":");//例如:23:59
             m3 = m1.at(0);//9
             m4 = m1.at(1);//59
             m5 = m2.at(0);//23
             m6 = m2.at(1);//59
             mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
             hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
             qDebug()<<m3<<m4<<"\n"<<m5<<m6<<"\n"<<hh<<mm<<endl;
            if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
            {
                 if(mm == 60)//小时加1
                 {
                     m4 = QString("0");
                     m3 = QString("0");
                 }
                 else//>60
                 {
                         //小时加1  并且拼接出分钟数值
                     if(( mm>=61) &&(mm<=69))//01-09
                     {
                         m4 = QString("%1").arg(mm%60).at(0);//余数时5
                         m3 = QString("0");
                     }
                     else
                     {
                         m4 = QString("%1").arg(mm%60).at(1);
                         m3 = QString("%1").arg(mm%60).at(0);
                     }
                 }
                 //小时计算和求值
                 if(hh >23)//半夜三更
                 {
                     h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                     h2 = QString("0");
                 }
                 else if(hh == 23)//晚上:00.00
                 {
                     h2 = QString("%1").arg(QString("0").toInt()+1);
                     h3 = QString("0");
                 }
                 else if(hh>=10&&hh<=22)
                {
                   QString temp  = QString("%1").arg(hh%24);//19
                   uint8_t  ret = temp.toInt()+1;//20  //11-23
                   h3 = QString("%1").arg(ret).at(1);
                    if(ret >= 20)
                    {
                        h2 = QString("%1").arg(ret).at(0);
                    }
                    else
                    {
                        h2 = QString("%1").arg(hh%24).at(0);
                    }
                }
                 else //hh<10
             {

                 QString temp  = QString("%1").arg(hh%24);//=9
                 uint8_t  ret = temp.toInt()+1;
                 if(ret ==10)//10:00
                 {
                          h2 = QString("1");
                          h3 = QString("0");
                 }
                 else {
                     h2 = QString("0");
                     h3 = QString("%1").arg(ret);
                 }
             }
            }
            else if(mm >= 100)//大于等于100   mm最大时59+59=118
            {
                 m4 = QString("%1").arg(mm%60).at(1);
                 m3 = QString("%1").arg(mm%60).at(0);
                 uint8_t rethh = mm/60;//转化为小时
                  //小时计算和求值
                  if(hh >23)//半夜三更
                  {
                      h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                      h2 = QString("0");
                  }
                  else if(hh == 23)//晚上:00.00
                  {
                      h2 = QString("%1").arg(QString("0").toInt()+rethh);
                      h3 = QString("0");
                  }
                  else if(hh>=10&&hh<=22)
                 {

                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt()+rethh;
                    h3 = QString("%1").arg(ret).at(1);
                     h2 = QString("%1").arg(hh%24).at(0);
                 }
                  else //<10
                  {

                      QString temp  = QString("%1").arg(hh%24);//=9
                      uint8_t  ret = temp.toInt()+rethh;
                      if(ret ==10)//10:00
                      {
                               h2 = QString("1");
                               h3 = QString("0");
                      }
                      else {
                          h2 = QString("0");
                          h3 = QString("%1").arg(ret);
                      }
                  }
            }
            else  if(mm<10 )
            {
                 m4 = QString("%1").arg(mm%60);
                 m3 = QString("%1").arg(0);
                 //小时计算和求值
                 if(hh >23)//半夜三更
                 {
                     h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                     h2 = QString("0");
                 }
                 else if(hh == 23)//晚上:00.00
                 {
                     h2 = QString("%1").arg(QString("0").toInt());
                     h3 = QString("0");
                 }
                 else if(hh>=10&&hh<=22)
                {

                   QString temp  = QString("%1").arg(hh%24);//=10
                   uint8_t  ret = temp.toInt();
                   h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
                }
                 else //<10
                 {
                     uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                     h2 = QString("0");
                     h3 = QString("%1").arg(temp);
                 }
            }
            else//     10<=mm>=59
             {
                     m4 = QString(QString("%1").arg(mm%60).at(1));
                     m3 = QString(QString("%1").arg(mm%60).at(0));
                     //小时计算和求值
                     if(hh >23)//半夜三更
                     {
                         h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                         h2 = QString("0");
                     }
                     else if(hh == 23)//晚上:00.00
                     {
                         h2 = QString("%1").arg(QString("0").toInt());
                         h3 = QString("0");
                     }
                     else if(hh>=10&&hh<=22)
                    {
                         QString temp  = QString("%1").arg(hh%24);//=10
                         uint8_t  ret = temp.toInt();
                         h3 = QString("%1").arg(ret).at(1);
                         h2 = QString("%1").arg(hh%24).at(0);
                    }
                     else //hh<10
                     {
                         uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                         h2 = QString("0");
                         h3 = QString("%1").arg(temp);
                     }
             }
             ui->label_Rinseendime->setText(QString("%1%2%3:%4%5").arg("结束时间 ").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
             ui->label_Rinsestarttime->show();
             ui->label_Rinseendime->show();
    }
    else if(Val == "酸洗")//15-999
    {
        static uint8_t flag =0;
        if(flag == 0)//第一次进入
        {
              Sys_time.clear();
              Sys_time = ui->label_time->text();//获取系统时间
              ui->label_Rinsestarttime->setText(tr(QString("开始时间 %1:%2").arg(Sys_time.split(":").at(0)).arg(Sys_time.split(":").at(1)).toUtf8().data()));
              flag =1;
        }
//        QString stage1_time_3 = QString("%1").arg(ui->stage1_time_3->text().split(" ").at(0));//酸洗前水洗
//        QString stage2_time_3 = QString("%1").arg(ui->stage2_time_3->text().split(" ").at(0));//酸洗
//        QString stage3_time_3 = QString("%1").arg(ui->stage3_time_3->text().split(" ").at(0));//酸洗浸泡
//        QString stage4_time_3 = QString("%1").arg(ui->stage4_time_3->text().split(" ").at(0));//酸洗后水洗
        QString stage1_time_3 = QString("%1").arg(data_lib->Get_Value(72).split(" ").at(0));//酸洗前水洗15
        QString stage2_time_3 = QString("%1").arg(data_lib->Get_Value(73).split(" ").at(0));//酸洗20
        QString stage3_time_3 = QString("%1").arg(data_lib->Get_Value(74).split(" ").at(0));//酸洗浸泡60
        QString stage4_time_3 = QString("%1").arg(data_lib->Get_Value(75).split(" ").at(0));//酸洗后水洗20
        uint8_t hmus,min;
        QString stage_time;
        uint32_t  Total_time = stage1_time_3.toInt()+stage2_time_3.toInt()+stage3_time_3.toInt()+stage4_time_3.toInt();
        if(Total_time >59)
        {
                hmus = Total_time/60;//小时
                min= Total_time%60;//分
                stage_time = QString("%1:%2").arg(hmus).arg(min);
        }
        else
        {
                 stage_time = QString("0:%1").arg(Total_time);
        }
        bool ok;
        uint32_t mm,hh;
        QStringList m1; QStringList m2;
        QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
        m1 = stage_time.split(":");//9:59
        m2 = Sys_time.split(":");//例如:23:59
        m3 = m1.at(0);//9
        m4 = m1.at(1);//59
        m5 = m2.at(0);//23
        m6 = m2.at(1);//59
        mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
        hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
        if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
        {
            if(mm == 60)//小时加1
            {
                m4 = QString("0");
                m3 = QString("0");
            }
            else//>60
            {
                    //小时加1  并且拼接出分钟数值
                if(( mm>=61) &&(mm<=69))//01-09
                {
                    m4 = QString("%1").arg(mm%60).at(0);//余数时5
                    m3 = QString("0");
                }
                else
                {
                    m4 = QString("%1").arg(mm%60).at(1);
                    m3 = QString("%1").arg(mm%60).at(0);
                }

            }
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt()+1);
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

                QString temp  = QString("%1").arg(hh%24);//19
                uint8_t  ret = temp.toInt()+1;//20  //11-23
                h3 = QString("%1").arg(ret).at(1);
                 if(ret >= 20)
                 {
                     h2 = QString("%1").arg(ret).at(0);
                 }
                 else
                 {
                     h2 = QString("%1").arg(hh%24).at(0);
                 }
           }
            else //<10
            {

                QString temp  = QString("%1").arg(hh%24);//=9
                uint8_t  ret = temp.toInt()+1;
                if(ret ==10)//10:00
                {
                         h2 = QString("1");
                         h3 = QString("0");
                }
                else {
                    h2 = QString("0");
                    h3 = QString("%1").arg(ret);
                }
            }
        }
        else if(mm >= 100)//大于等于100   mm最大时59+59=118
        {
            m4 = QString("%1").arg(mm%60).at(1);
            m3 = QString("%1").arg(mm%60).at(0);
            uint8_t rethh = mm/60;//转化为小时
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt()+rethh);
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {

               QString temp  = QString("%1").arg(hh%24);//=10
               uint8_t  ret = temp.toInt()+rethh;
               h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
            }
             else //<10
             {

                 QString temp  = QString("%1").arg(hh%24);//=9
                 uint8_t  ret = temp.toInt()+rethh;
                 if(ret ==10)//10:00
                 {
                          h2 = QString("1");
                          h3 = QString("0");
                 }
                 else {
                     h2 = QString("0");
                     h3 = QString("%1").arg(ret);
                 }
             }
        }
       else  if(mm<10 )
        {
            m4 = QString("%1").arg(mm%60);
            m3 = QString("%1").arg(0);
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt());
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

              QString temp  = QString("%1").arg(hh%24);//=10
              uint8_t  ret = temp.toInt();
              h3 = QString("%1").arg(ret).at(1);
               h2 = QString("%1").arg(hh%24).at(0);
           }
            else //<10
            {
                uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                h2 = QString("0");
                h3 = QString("%1").arg(temp);
            }
        }
        else//     10<=mm>=59
        {
                m4 = QString(QString("%1").arg(mm%60).at(1));
                m3 = QString(QString("%1").arg(mm%60).at(0));
                //小时计算和求值
                if(hh >23)//半夜三更
                {
                    h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                    h2 = QString("0");
                }
                else if(hh == 23)//晚上:00.00
                {
                    h2 = QString("%1").arg(QString("0").toInt());
                    h3 = QString("0");
                }
                else if(hh>=10&&hh<=22)
               {
                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt();
                    h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
               }
                else //<10
                {
                    uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                    h2 = QString("0");
                    h3 = QString("%1").arg(temp);
                }
        }
            ui->label_Rinseendime->setText(QString("%1%2%3:%4%5").arg("结束时间 ").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
            ui->label_Rinsestarttime->show();
            ui->label_Rinseendime->show();
    }
    else if(Val == "过氧乙酸清洗")
    {
        static uint8_t flag =0;
        if(flag == 0)//第一次进入
        {
             Sys_time.clear();
              Sys_time = ui->label_time->text();//获取系统时间
              ui->label_Rinsestarttime->setText(tr(QString("开始时间 %1:%2").arg(Sys_time.split(":").at(0)).arg(Sys_time.split(":").at(1)).toUtf8().data()));
              flag =1;
        }
//        QString stage1_time_2 = QString("%1").arg(ui->stage1_time_1->text().split(" ").at(0));//清洗前水洗
//        QString stage2_time_2 = QString("%1").arg(ui->stage2_time_2->text().split(" ").at(0));//过氧乙酸清洗
//        QString stage3_time_2 = QString("%1").arg(ui->stage3_time_2->text().split(" ").at(0));//过氧乙酸浸泡
//        QString stage4_time_2 = QString("%1").arg(ui->stage4_time_2->text().split(" ").at(0));//清洗后水洗
        QString stage1_time_2 = QString("%1").arg(data_lib->Get_Value(92).split(" ").at(0));//清洗前水洗
        QString stage2_time_2 = QString("%1").arg(data_lib->Get_Value(93).split(" ").at(0));//过氧乙酸清洗
        QString stage3_time_2 = QString("%1").arg(data_lib->Get_Value(94).split(" ").at(0));//过氧乙酸浸泡
        QString stage4_time_2 = QString("%1").arg(data_lib->Get_Value(95).split(" ").at(0));//清洗后水洗
        uint8_t hmus,min;
        QString stage_time;
        uint32_t  Total_time = stage1_time_2.toInt()+stage2_time_2.toInt()+stage3_time_2.toInt()+stage4_time_2.toInt();
        if(Total_time >59)
        {
                hmus = Total_time/60;//小时
                min= Total_time%60;//分
                stage_time = QString("%1:%2").arg(hmus).arg(min);
        }
        else
        {
                 stage_time = QString("0:%1").arg(Total_time);
        }
        bool ok;
        uint32_t mm,hh;
        QStringList m1; QStringList m2;
        QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
        m1 = stage_time.split(":");//9:59
        m2 = Sys_time.split(":");//例如:23:59
        m3 = m1.at(0);//9
        m4 = m1.at(1);//59
        m5 = m2.at(0);//23
        m6 = m2.at(1);//59
        mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
        hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
        qDebug()<<m3<<m4<<"\n"<<m5<<m6<<"\n"<<hh<<mm<<endl;
        if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
        {
            if(mm == 60)//小时加1
            {
                m4 = QString("0");
                m3 = QString("0");
            }
            else//>60
            {
                    //小时加1  并且拼接出分钟数值
                if(( mm>=61) &&(mm<=69))//01-09
                {
                    m4 = QString("%1").arg(mm%60).at(0);//余数时5
                    m3 = QString("0");
                }
                else
                {
                    m4 = QString("%1").arg(mm%60).at(1);
                    m3 = QString("%1").arg(mm%60).at(0);
                }
            }
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt()+1);
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

                QString temp  = QString("%1").arg(hh%24);//19
                uint8_t  ret = temp.toInt()+1;//20  //11-23
                h3 = QString("%1").arg(ret).at(1);
                 if(ret >= 20)
                 {
                     h2 = QString("%1").arg(ret).at(0);
                 }
                 else
                 {
                     h2 = QString("%1").arg(hh%24).at(0);
                 }
           }
            else //<10
            {

                QString temp  = QString("%1").arg(hh%24);//=9
                uint8_t  ret = temp.toInt()+1;
                if(ret ==10)//10:00
                {
                         h2 = QString("1");
                         h3 = QString("0");
                }
                else {
                    h2 = QString("0");
                    h3 = QString("%1").arg(ret);
                }
            }
        }
        else if(mm >= 100)//大于等于100   mm最大时59+59=118
        {
            m4 = QString("%1").arg(mm%60).at(1);
            m3 = QString("%1").arg(mm%60).at(0);
            uint8_t rethh = mm/60;//转化为小时
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt()+rethh);
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {

               QString temp  = QString("%1").arg(hh%24);//=10
               uint8_t  ret = temp.toInt()+rethh;
               h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
            }
             else //<10
             {

                 QString temp  = QString("%1").arg(hh%24);//=9
                 uint8_t  ret = temp.toInt()+rethh;
                 if(ret ==10)//10:00
                 {
                          h2 = QString("1");
                          h3 = QString("0");
                 }
                 else {
                     h2 = QString("0");
                     h3 = QString("%1").arg(ret);
                 }
             }
        }
       else  if(mm<10 )
        {
            m4 = QString("%1").arg(mm%60);
            m3 = QString("%1").arg(0);
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt());
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

              QString temp  = QString("%1").arg(hh%24);//=10
              uint8_t  ret = temp.toInt();
              h3 = QString("%1").arg(ret).at(1);
               h2 = QString("%1").arg(hh%24).at(0);
           }
            else //<10
            {
                uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                h2 = QString("0");
                h3 = QString("%1").arg(temp);
            }
        }
        else//     10<=mm>=59
        {
                m4 = QString(QString("%1").arg(mm%60).at(1));
                m3 = QString(QString("%1").arg(mm%60).at(0));
                //小时计算和求值
                if(hh >23)//半夜三更
                {
                    h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                    h2 = QString("0");
                }
                else if(hh == 23)//晚上:00.00
                {
                    h2 = QString("%1").arg(QString("0").toInt());
                    h3 = QString("0");
                }
                else if(hh>=10&&hh<=22)
               {
                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt();
                    h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
               }
                else //<10
                {
                    uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                    h2 = QString("0");
                    h3 = QString("%1").arg(temp);
                }
        }
            ui->label_Rinseendime->setText(QString("%1%2%3:%4%5").arg("结束时间 ").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
            ui->label_Rinsestarttime->show();
            ui->label_Rinseendime->show();
    }
    else if(Val == "消毒")
    {

        static uint8_t flag =0;
        if(flag == 0)//第一次进入
        {
              Sys_time.clear();
              Sys_time = ui->label_time->text();//获取系统时间
              ui->label_Rinsestarttime->setText(tr(QString("开始时间 %1:%2").arg(Sys_time.split(":").at(0)).arg(Sys_time.split(":").at(1)).toUtf8().data()));
              flag =1;
        }
//        QString stage1_time_4 = QString("%1").arg(ui->stage1_time_4->text().split(" ").at(0));//消毒前水洗
//        QString stage2_time_4 = QString("%1").arg(ui->stage2_time_4->text().split(" ").at(0));//消毒
//        QString stage3_time_4 = QString("%1").arg(ui->stage3_time_4->text().split(" ").at(0));//消毒静置
//        QString stage4_time_4 = QString("%1").arg(ui->stage4_time_4->text().split(" ").at(0));//消毒后水洗
        QString stage1_time_4 = QString("%1").arg(data_lib->Get_Value(77).split(" ").at(0));//消毒前水洗
        QString stage2_time_4 = QString("%1").arg(data_lib->Get_Value(78).split(" ").at(0));//消毒
        QString stage3_time_4 = QString("%1").arg(data_lib->Get_Value(79).split(" ").at(0));//消毒静置
        QString stage4_time_4 = QString("%1").arg(data_lib->Get_Value(80).split(" ").at(0));//消毒后水洗
        uint8_t hmus,min;
        QString stage_time;
        uint32_t  Total_time = stage1_time_4.toInt()+stage2_time_4.toInt()+stage3_time_4.toInt()+stage4_time_4.toInt();
        if(Total_time >59)
        {
                hmus = Total_time/60;//小时
                min= Total_time%60;//分
                stage_time = QString("%1:%2").arg(hmus).arg(min);
        }
        else
        {
                 stage_time = QString("0:%1").arg(Total_time);
        }
        bool ok;
        uint32_t mm,hh;
        QStringList m1; QStringList m2;
        QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
        m1 = stage_time.split(":");//9:59
        m2 = Sys_time.split(":");//例如:23:59
        m3 = m1.at(0);//9
        m4 = m1.at(1);//59
        m5 = m2.at(0);//23
        m6 = m2.at(1);//59
        mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
        hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
        qDebug()<<m3<<m4<<"\n"<<m5<<m6<<"\n"<<hh<<mm<<endl;
        if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
        {
            if(mm == 60)//小时加1
            {
                m4 = QString("0");
                m3 = QString("0");
            }
            else//>60
            {
                    //小时加1  并且拼接出分钟数值
                if(( mm>=61) &&(mm<=69))//01-09
                {
                    m4 = QString("%1").arg(mm%60).at(0);//余数时5
                    m3 = QString("0");
                }
                else
                {
                    m4 = QString("%1").arg(mm%60).at(1);
                    m3 = QString("%1").arg(mm%60).at(0);
                }
            }
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt()+1);
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

                QString temp  = QString("%1").arg(hh%24);//19
                uint8_t  ret = temp.toInt()+1;//20  //11-23
                h3 = QString("%1").arg(ret).at(1);
                 if(ret >= 20)
                 {
                     h2 = QString("%1").arg(ret).at(0);
                 }
                 else
                 {
                     h2 = QString("%1").arg(hh%24).at(0);
                 }
           }
            else //<10
            {

                QString temp  = QString("%1").arg(hh%24);//=9
                uint8_t  ret = temp.toInt()+1;
                if(ret ==10)//10:00
                {
                         h2 = QString("1");
                         h3 = QString("0");
                }
                else {
                    h2 = QString("0");
                    h3 = QString("%1").arg(ret);
                }
            }
        }
        else if(mm >= 100)//大于等于100   mm最大时59+59=118
        {
            m4 = QString("%1").arg(mm%60).at(1);
            m3 = QString("%1").arg(mm%60).at(0);
            uint8_t rethh = mm/60;//转化为小时
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt()+rethh);
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {

               QString temp  = QString("%1").arg(hh%24);//=10
               uint8_t  ret = temp.toInt()+rethh;
               h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
            }
             else //<10
             {

                 QString temp  = QString("%1").arg(hh%24);//=9
                 uint8_t  ret = temp.toInt()+rethh;
                 if(ret ==10)//10:00
                 {
                          h2 = QString("1");
                          h3 = QString("0");
                 }
                 else {
                     h2 = QString("0");
                     h3 = QString("%1").arg(ret);
                 }
             }
        }
       else  if(mm<10 )
        {
            m4 = QString("%1").arg(mm%60);
            m3 = QString("%1").arg(0);
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt());
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

              QString temp  = QString("%1").arg(hh%24);//=10
              uint8_t  ret = temp.toInt();
              h3 = QString("%1").arg(ret).at(1);
               h2 = QString("%1").arg(hh%24).at(0);
           }
            else //<10
            {
                uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                h2 = QString("0");
                h3 = QString("%1").arg(temp);
            }
        }
        else//     10<=mm>=59
        {
                m4 = QString(QString("%1").arg(mm%60).at(1));
                m3 = QString(QString("%1").arg(mm%60).at(0));
                //小时计算和求值
                if(hh >23)//半夜三更
                {
                    h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                    h2 = QString("0");
                }
                else if(hh == 23)//晚上:00.00
                {
                    h2 = QString("%1").arg(QString("0").toInt());
                    h3 = QString("0");
                }
                else if(hh>=10&&hh<=22)
               {
                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt();
                    h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
               }
                else //<10
                {
                    uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                    h2 = QString("0");
                    h3 = QString("%1").arg(temp);
                }
        }
            ui->label_Rinseendime->setText(QString("%1%2%3:%4%5").arg("结束时间 ").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
            ui->label_Rinsestarttime->show();
            ui->label_Rinseendime->show();
    }
    else if(Val == "热水冲洗")
    {
        static uint8_t flag =0;
        if(flag == 0)//第一次进入
        {
              Sys_time.clear();
              Sys_time = ui->label_time->text();//获取系统时间
              ui->label_Rinsestarttime->setText(tr(QString("开始时间 %1:%2").arg(Sys_time.split(":").at(0)).arg(Sys_time.split(":").at(1)).toUtf8().data()));
              flag =1;
        }
//        QString stage1_time_5 = QString("%1").arg(ui->stage1_time_5->text().split(" ").at(0));//热冲洗前水洗
//        QString stage2_time_5 = QString("%1").arg(5);//加热
//        QString stage3_time_5 = QString("%1").arg(ui->stage3_time_5->text().split(" ").at(0));//热水冲洗
//        QString stage4_time_5 = QString("%1").arg(5);//冷却
//        QString stage5_time_5 = QString("%1").arg(ui->stage5_time_5->text().split(" ").at(0));//热冲洗后水洗
        QString stage1_time_5 = QString("%1").arg(data_lib->Get_Value(83).split(" ").at(0));//热冲洗前水洗
        QString stage2_time_5 = QString("%1").arg(5);//加热
        QString stage3_time_5 = QString("%1").arg(data_lib->Get_Value(84).split(" ").at(0));//热水冲洗
        QString stage4_time_5 = QString("%1").arg(5);//冷却
        QString stage5_time_5 = QString("%1").arg(data_lib->Get_Value(85).split(" ").at(0));//热冲洗后水洗
        uint8_t hmus,min;
        QString stage_time;
        uint32_t  Total_time = stage1_time_5.toInt()+stage2_time_5.toInt()+stage3_time_5.toInt()+stage5_time_5.toInt()+stage4_time_5.toInt();
        if(Total_time >59)
        {
                hmus = Total_time/60;//小时
                min= Total_time%60;//分
                stage_time = QString("%1:%2").arg(hmus).arg(min);
        }
        else
        {
                 stage_time = QString("0:%1").arg(Total_time);
        }
        bool ok;
        uint32_t mm,hh;
        QStringList m1; QStringList m2;
        QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
        m1 = stage_time.split(":");//9:59
        m2 = Sys_time.split(":");//例如:23:59
        m3 = m1.at(0);//9
        m4 = m1.at(1);//59
        m5 = m2.at(0);//23
        m6 = m2.at(1);//59
        mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
        hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
        qDebug()<<m3<<m4<<"\n"<<m5<<m6<<"\n"<<hh<<mm<<endl;
        if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
        {
            if(mm == 60)//小时加1
            {
                m4 = QString("0");
                m3 = QString("0");
            }
            else//>60
            {
                    //小时加1  并且拼接出分钟数值
                if(( mm>=61) &&(mm<=69))//01-09
                {
                    m4 = QString("%1").arg(mm%60).at(0);//余数时5
                    m3 = QString("0");
                }
                else
                {
                    m4 = QString("%1").arg(mm%60).at(1);
                    m3 = QString("%1").arg(mm%60).at(0);
                }
            }
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt()+1);
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

                QString temp  = QString("%1").arg(hh%24);//19
                uint8_t  ret = temp.toInt()+1;//20  //11-23
                h3 = QString("%1").arg(ret).at(1);
                 if(ret >= 20)
                 {
                     h2 = QString("%1").arg(ret).at(0);
                 }
                 else
                 {
                     h2 = QString("%1").arg(hh%24).at(0);
                 }
           }
            else //<10
            {

                QString temp  = QString("%1").arg(hh%24);//=9
                uint8_t  ret = temp.toInt()+1;
                if(ret ==10)//10:00
                {
                         h2 = QString("1");
                         h3 = QString("0");
                }
                else {
                    h2 = QString("0");
                    h3 = QString("%1").arg(ret);
                }
            }
        }
        else if(mm >= 100)//大于等于100   mm最大时59+59=118
        {
            m4 = QString("%1").arg(mm%60).at(1);
            m3 = QString("%1").arg(mm%60).at(0);
            uint8_t rethh = mm/60;//转化为小时
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt()+rethh);
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {

               QString temp  = QString("%1").arg(hh%24);//=10
               uint8_t  ret = temp.toInt()+rethh;
               h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
            }
             else //<10
             {

                 QString temp  = QString("%1").arg(hh%24);//=9
                 uint8_t  ret = temp.toInt()+rethh;
                 if(ret ==10)//10:00
                 {
                          h2 = QString("1");
                          h3 = QString("0");
                 }
                 else {
                     h2 = QString("0");
                     h3 = QString("%1").arg(ret);
                 }
             }
        }
       else  if(mm<10 )
        {
            m4 = QString("%1").arg(mm%60);
            m3 = QString("%1").arg(0);
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt());
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

              QString temp  = QString("%1").arg(hh%24);//=10
              uint8_t  ret = temp.toInt();
              h3 = QString("%1").arg(ret).at(1);
               h2 = QString("%1").arg(hh%24).at(0);
           }
            else //<10
            {
                uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                h2 = QString("0");
                h3 = QString("%1").arg(temp);
            }
        }
        else//     10<=mm>=59
        {
                m4 = QString(QString("%1").arg(mm%60).at(1));
                m3 = QString(QString("%1").arg(mm%60).at(0));
                //小时计算和求值
                if(hh >23)//半夜三更
                {
                    h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                    h2 = QString("0");
                }
                else if(hh == 23)//晚上:00.00
                {
                    h2 = QString("%1").arg(QString("0").toInt());
                    h3 = QString("0");
                }
                else if(hh>=10&&hh<=22)
               {
                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt();
                    h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
               }
                else //<10
                {
                    uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                    h2 = QString("0");
                    h3 = QString("%1").arg(temp);
                }
        }
            ui->label_Rinseendime->setText(QString("%1%2%3:%4%5").arg("结束时间 ").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
            ui->label_Rinsestarttime->show();
            ui->label_Rinseendime->show();
    }
    else if(Val == "热水柠檬酸洗")
    {
        static uint8_t flag =0;
        if(flag == 0)//第一次进入
        {
              Sys_time.clear();
              Sys_time = ui->label_time->text();//获取系统时间
              ui->label_Rinsestarttime->setText(tr(QString("开始时间 %1:%2").arg(Sys_time.split(":").at(0)).arg(Sys_time.split(":").at(1)).toUtf8().data()));
              flag =1;
        }
//        QString stage1_time_6 = QString("%1").arg(ui->stage1_time_6->text().split(" ").at(0));//清洗前水洗
//        QString stage2_time_6 = QString("%1").arg(5);//加热
//        QString stage3_time_6 = QString("%1").arg(ui->stage3_time_6->text().split(" ").at(0));//热水柠檬酸洗
//        QString stage4_time_6 = QString("%1").arg(5);//冷却
//        QString stage5_time_6 = QString("%1").arg(ui->stage5_time_6->text().split(" ").at(0));//热冲洗后水洗
        QString stage1_time_6 = QString("%1").arg(data_lib->Get_Value(87).split(" ").at(0));//清洗前水洗
        QString stage2_time_6 = QString("%1").arg(5);//加热
        QString stage3_time_6 = QString("%1").arg(data_lib->Get_Value(88).split(" ").at(0));//热水柠檬酸洗
        QString stage4_time_6 = QString("%1").arg(5);//冷却
        QString stage5_time_6 = QString("%1").arg(data_lib->Get_Value(89).split(" ").at(0));//热冲洗后水洗
        uint8_t hmus,min;
        QString stage_time;
        uint32_t  Total_time = stage1_time_6.toInt()+stage2_time_6.toInt()+stage3_time_6.toInt()+stage5_time_6.toInt()+stage4_time_6.toInt();
        if(Total_time >59)
        {
                hmus = Total_time/60;//小时
                min= Total_time%60;//分
                stage_time = QString("%1:%2").arg(hmus).arg(min);
        }
        else
        {
                 stage_time = QString("0:%1").arg(Total_time);
        }
        bool ok;
        uint32_t mm,hh;
        QStringList m1; QStringList m2;
        QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
        m1 = stage_time.split(":");//9:59
        m2 = Sys_time.split(":");//例如:23:59
        m3 = m1.at(0);//9
        m4 = m1.at(1);//59
        m5 = m2.at(0);//23
        m6 = m2.at(1);//59
        mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
        hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
        qDebug()<<m3<<m4<<"\n"<<m5<<m6<<"\n"<<hh<<mm<<endl;
        if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
        {
            if(mm == 60)//小时加1
            {
                m4 = QString("0");
                m3 = QString("0");
            }
            else//>60
            {
                    //小时加1  并且拼接出分钟数值
                if(( mm>=61) &&(mm<=69))//01-09
                {
                    m4 = QString("%1").arg(mm%60).at(0);//余数时5
                    m3 = QString("0");
                }
                else
                {
                    m4 = QString("%1").arg(mm%60).at(1);
                    m3 = QString("%1").arg(mm%60).at(0);
                }
            }
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt()+1);
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

                QString temp  = QString("%1").arg(hh%24);//19
                uint8_t  ret = temp.toInt()+1;//20  //11-23
                h3 = QString("%1").arg(ret).at(1);
                 if(ret >= 20)
                 {
                     h2 = QString("%1").arg(ret).at(0);
                 }
                 else
                 {
                     h2 = QString("%1").arg(hh%24).at(0);
                 }
           }
            else //<10
            {

                QString temp  = QString("%1").arg(hh%24);//=9
                uint8_t  ret = temp.toInt()+1;
                if(ret ==10)//10:00
                {
                         h2 = QString("1");
                         h3 = QString("0");
                }
                else {
                    h2 = QString("0");
                    h3 = QString("%1").arg(ret);
                }
            }
        }
        else if(mm >= 100)//大于等于100   mm最大时59+59=118
        {
            m4 = QString("%1").arg(mm%60).at(1);
            m3 = QString("%1").arg(mm%60).at(0);
            uint8_t rethh = mm/60;//转化为小时
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt()+rethh);
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {

               QString temp  = QString("%1").arg(hh%24);//=10
               uint8_t  ret = temp.toInt()+rethh;
               h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
            }
             else //<10
             {

                 QString temp  = QString("%1").arg(hh%24);//=9
                 uint8_t  ret = temp.toInt()+rethh;
                 if(ret ==10)//10:00
                 {
                          h2 = QString("1");
                          h3 = QString("0");
                 }
                 else {
                     h2 = QString("0");
                     h3 = QString("%1").arg(ret);
                 }
             }
        }
       else  if(mm<10 )
        {
            m4 = QString("%1").arg(mm%60);
            m3 = QString("%1").arg(0);
            //小时计算和求值
            if(hh >23)//半夜三更
            {
                h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                h2 = QString("0");
            }
            else if(hh == 23)//晚上:00.00
            {
                h2 = QString("%1").arg(QString("0").toInt());
                h3 = QString("0");
            }
            else if(hh>=10&&hh<=22)
           {

              QString temp  = QString("%1").arg(hh%24);//=10
              uint8_t  ret = temp.toInt();
              h3 = QString("%1").arg(ret).at(1);
               h2 = QString("%1").arg(hh%24).at(0);
           }
            else //<10
            {
                uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                h2 = QString("0");
                h3 = QString("%1").arg(temp);
            }
        }
        else//     10<=mm>=59
        {
                m4 = QString(QString("%1").arg(mm%60).at(1));
                m3 = QString(QString("%1").arg(mm%60).at(0));
                //小时计算和求值
                if(hh >23)//半夜三更
                {
                    h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                    h2 = QString("0");
                }
                else if(hh == 23)//晚上:00.00
                {
                    h2 = QString("%1").arg(QString("0").toInt());
                    h3 = QString("0");
                }
                else if(hh>=10&&hh<=22)
               {
                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt();
                    h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
               }
                else //<10
                {
                    uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                    h2 = QString("0");
                    h3 = QString("%1").arg(temp);
                }
        }
            ui->label_Rinseendime->setText(QString("%1%2%3:%4%5").arg("结束时间 ").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
            ui->label_Rinsestarttime->show();
            ui->label_Rinseendime->show();
    }
    else if(Val == "强制冲洗")
    {
        static uint8_t flag =0;
        if(flag == 0)//第一次进入
        {
              Sys_time.clear();
              MandatoryRinse.clear();
              Sys_time = ui->label_time->text();//获取系统时间
              ui->label_Rinsestarttime->setText(tr(QString("开始时间 %1:%2").arg(Sys_time.split(":").at(0)).arg(Sys_time.split(":").at(1)).toUtf8().data()));
              MandatoryRinse = QString("0:%1").arg(ui->label_rinseleft->text().split(" ").at(0));//强制冲洗分钟
              flag =1;//一直保留这个值
        }
        //QString Water_time = QString("%1").arg(data_lib->Get_Value(71));//水洗时间分钟
        uint32_t hmus,min;
        uint32_t Total_time=MandatoryRinse.toInt();
        if(Total_time >59)
        {
                MandatoryRinse.clear();
                hmus = Total_time/60;//小时
                min= Total_time%60;//分
                MandatoryRinse = QString("%1:%2").arg(hmus).arg(min);
        }
        else
        {
                 MandatoryRinse.clear();
                 MandatoryRinse = QString("0:%1").arg(Total_time);
        }
         bool ok;
         uint32_t mm,hh;
         QStringList m1; QStringList m2;
         QString m3; QString m4;  QString m5; QString m6;  QString h3; QString h2;
         m1 = MandatoryRinse.split(":");//9:59
         m2 = Sys_time.split(":");//例如:23:59
         m3 = m1.at(0);//9
         m4 = m1.at(1);//59
         m5 = m2.at(0);//23
         m6 = m2.at(1);//59
         mm =m4.toInt(&ok,10)+m6.toInt(&ok,10);//分钟
         hh =m3.toInt(&ok,10)+m5.toInt(&ok,10);//小时
         qDebug()<<m3<<m4<<"\n"<<m5<<m6<<"\n"<<hh<<mm<<endl;
        if((mm >=60)&&(mm <100))//分钟不能大于60   大于增加一个小时
        {
             if(mm == 60)//小时加1
             {
                 m4 = QString("0");
                 m3 = QString("0");
             }
             else//>60
             {
                     //小时加1  并且拼接出分钟数值
                 if(( mm>=61) &&(mm<=69))//01-09
                 {
                     m4 = QString("%1").arg(mm%60).at(0);//余数时5
                     m3 = QString("0");
                 }
                 else
                 {
                     m4 = QString("%1").arg(mm%60).at(1);
                     m3 = QString("%1").arg(mm%60).at(0);
                 }
             }
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+1);
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt()+1);
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {
               QString temp  = QString("%1").arg(hh%24);//19
               uint8_t  ret = temp.toInt()+1;//20  //11-23
               h3 = QString("%1").arg(ret).at(1);
                if(ret >= 20)
                {
                    h2 = QString("%1").arg(ret).at(0);
                }
                else
                {
                    h2 = QString("%1").arg(hh%24).at(0);
                }
            }
             else //<10
         {

             QString temp  = QString("%1").arg(hh%24);//=9
             uint8_t  ret = temp.toInt()+1;
             if(ret ==10)//10:00
             {
                      h2 = QString("1");
                      h3 = QString("0");
             }
             else {
                 h2 = QString("0");
                 h3 = QString("%1").arg(ret);
             }
         }
        }
        else if(mm >= 100)//大于等于100   mm最大时59+59=118
        {
             m4 = QString("%1").arg(mm%60).at(1);
             m3 = QString("%1").arg(mm%60).at(0);
             uint8_t rethh = mm/60;//转化为小时
              //小时计算和求值
              if(hh >23)//半夜三更
              {
                  h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt()+rethh);
                  h2 = QString("0");
              }
              else if(hh == 23)//晚上:00.00
              {
                  h2 = QString("%1").arg(QString("0").toInt()+rethh);
                  h3 = QString("0");
              }
              else if(hh>=10&&hh<=22)
             {

                QString temp  = QString("%1").arg(hh%24);//=10
                uint8_t  ret = temp.toInt()+rethh;
                h3 = QString("%1").arg(ret).at(1);
                 h2 = QString("%1").arg(hh%24).at(0);
             }
              else //<10
              {

                  QString temp  = QString("%1").arg(hh%24);//=9
                  uint8_t  ret = temp.toInt()+rethh;
                  if(ret ==10)//10:00
                  {
                           h2 = QString("1");
                           h3 = QString("0");
                  }
                  else {
                      h2 = QString("0");
                      h3 = QString("%1").arg(ret);
                  }
              }
        }
        else  if(mm<10 )
        {
             m4 = QString("%1").arg(mm%60);
             m3 = QString("%1").arg(0);
             //小时计算和求值
             if(hh >23)//半夜三更
             {
                 h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                 h2 = QString("0");
             }
             else if(hh == 23)//晚上:00.00
             {
                 h2 = QString("%1").arg(QString("0").toInt());
                 h3 = QString("0");
             }
             else if(hh>=10&&hh<=22)
            {

               QString temp  = QString("%1").arg(hh%24);//=10
               uint8_t  ret = temp.toInt();
               h3 = QString("%1").arg(ret).at(1);
                h2 = QString("%1").arg(hh%24).at(0);
            }
             else //<10
             {
                 uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                 h2 = QString("0");
                 h3 = QString("%1").arg(temp);
             }
        }
        else//     10<=mm>=59
         {
                m4 = QString(QString("%1").arg(mm%60).at(1));
                m3 = QString(QString("%1").arg(mm%60).at(0));
                //小时计算和求值
                if(hh >23)//半夜三更
                {
                    h3 = QString("%1").arg(QString("%1").arg(hh%24).toInt());
                    h2 = QString("0");
                }
                else if(hh == 23)//晚上:00.00
                {
                    h2 = QString("%1").arg(QString("0").toInt());
                    h3 = QString("0");
                }
                else if(hh>=10&&hh<=22)
               {
                    QString temp  = QString("%1").arg(hh%24);//=10
                    uint8_t  ret = temp.toInt();
                    h3 = QString("%1").arg(ret).at(1);
                    h2 = QString("%1").arg(hh%24).at(0);
               }
                else //<10
                {
                    uint8_t temp  = QString("%1").arg(hh%24).toInt();//=9
                    h2 = QString("0");
                    h3 = QString("%1").arg(temp);
                }
         }
         ui->label_Rinseendime->setText(QString("%1%2%3:%4%5").arg("结束时间 ").arg(h2).arg(h3).arg(m3).arg(m4));//总治疗剩余时间
         ui->label_Rinsestarttime->show();
         ui->label_Rinseendime->show();
    }
    else
    {
        //扩展
    }
}

实现的效果

QT如何实现将两个时间相加  qt 第6张

QT如何实现将两个时间相加  qt 第7张

“QT如何实现将两个时间相加”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注蜗牛博客网站,小编将为大家输出更多高质量的实用文章!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论Telegram