init
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
#include "timebridge.h"
|
||||
|
||||
#include <QLocale>
|
||||
#include <QTime>
|
||||
|
||||
QString TimeBridge::currentTimeString(bool includeSeconds) const {
|
||||
const auto format =
|
||||
includeSeconds ? QLocale::LongFormat : QLocale::ShortFormat;
|
||||
return QLocale().toString(QTime::currentTime(), format);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <qqmlintegration.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class TimeBridge : public QObject {
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
|
||||
public:
|
||||
using QObject::QObject;
|
||||
|
||||
Q_INVOKABLE QString currentTimeString(bool includeSeconds) const;
|
||||
};
|
||||
Reference in New Issue
Block a user