#include "currenttime.h" #include #include #include CurrentTime::CurrentTime(QObject *parent) : QObject(parent) { QTimer *timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &CurrentTime::showTime); timer->start(1000); } QString CurrentTime::showTime() { m_showTime = QTime::currentTime().toString("hh:mm:ss"); qDebug(m_showTime.toLatin1()); return m_showTime; } void CurrentTime::setShowTime(const QString &showTime) { if (showTime == m_showTime) return; else { m_showTime = showTime; emit showTimeChanged(); } }