I guess this solution is sufficient for you
constructor
: m_time
(QTime(0,
0,
0)){
ui.clock->setText(m_time.toString("hh:mm:ss"));
}
showtime
{
m_time = m_time.addSecs(1);
ui.clock->setText(m_time.toString("hh:mm:ss"));
}
constructor : m_time(QTime(0,0,0))
{
ui.clock->setText(m_time.toString("hh:mm:ss"));
}
showtime
{
m_time = m_time.addSecs(1);
ui.clock->setText(m_time.toString("hh:mm:ss"));
}
To copy to clipboard, switch view to plain text mode
Added after 6 minutes:
To be more precise:
constructor
: m_time
(QTime::currentTime()){
ui.
clock->setText
(QTime(0,
0,
0).
toString("hh:mm:ss"));
}
showtime
{
ui.
clock->setText
(QTime(0,
0,
0).
addSecs(m_time.
secsTo(QTime::currentTime())).
toString("hh:mm:ss"));
}
constructor : m_time(QTime::currentTime())
{
ui.clock->setText(QTime(0,0,0).toString("hh:mm:ss"));
}
showtime
{
ui.clock->setText(QTime(0,0,0).addSecs(m_time.secsTo(QTime::currentTime())).toString("hh:mm:ss"));
}
To copy to clipboard, switch view to plain text mode
Bookmarks