Qt 计时器

QTimer *m_sim_timer = new QTimer(this);
connect(m_sim_timer, SIGNAL(timeout()), this, SLOT(updateSimTime()));

m_timerecord = new QTime(0,0,0);

 

void CTaskWidget::updateSimTime()
{
*m_timerecord = m_timerecord->addMSecs(82);
int all_sec = m_timerecord->hour() * 3600 + m_timerecord->minute() * 60 + m_timerecord->second();
int msec = m_timerecord->msec();
QString simtime = QString("%1.%2").arg(all_sec, 10, 10, QLatin1Char('0')).arg(msec,4, 10, QLatin1Char('0'));
//QString simtime = QString::number(all_sec) + "." + QString::number(msec);
ui.SimTimelabel->setText(simtime);
}

posted @ 2019-05-16 16:50  Truman001  阅读(657)  评论(0编辑  收藏  举报