blob: d8e52755713160fb82398f09a2a2572b3a2e7097 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <QTimer>
#include <QTime>
#include <qdeclarative.h>
#include "mytype.h"
MyType::MyType(QObject *parent)
: QObject(parent)
{
updateTimerText();
m_timer = new QTimer(this);
m_timer->setInterval(1000);
connect(m_timer, SIGNAL(timeout()), SLOT(updateTimerText()));
m_timer->start();
}
QString MyType::timeText() const
{
// bp here should be hit on every second
return m_timeText;
}
void MyType::setTimeText(const QString &text)
{
if (m_timeText != text) {
m_timeText = text;
emit timeChanged(m_timeText);
}
}
void MyType::updateTimerText()
{
const QTime t = QTime::currentTime();
setTimeText(t.toString(QLatin1String("HH:mm:ss")));
}
QML_DECLARE_TYPE(MyType)
|