本文整理汇总了C++中QTime::msecsSinceStartOfDay方法的典型用法代码示例。如果您正苦于以下问题:C++ QTime::msecsSinceStartOfDay方法的具体用法?C++ QTime::msecsSinceStartOfDay怎么用?C++ QTime::msecsSinceStartOfDay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTime
的用法示例。
在下文中一共展示了QTime::msecsSinceStartOfDay方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debugPositionUpdate
void GPSDisplay::debugPositionUpdate()
{
#if MAPPER_DEVELOPMENT_BUILD
if (! visible)
return;
QTime now = QTime::currentTime();
float offset = now.msecsSinceStartOfDay() / (float)(10 * 1000);
float accuracy = 12 + 7 * qSin(2 + offset);
float altitude = 400 + 10 * qSin(1 + 0.1f * offset);
MapCoordF coord(30 * qSin(0.5f * offset), 30 * qCos(0.53f * offset));
emit mapPositionUpdated(coord, accuracy);
if (georeferencing.isValid() && ! georeferencing.isLocal())
{
bool ok;
LatLon latLon = georeferencing.toGeographicCoords(coord, &ok);
if (ok)
{
emit latLonUpdated(latLon.latitude(), latLon.longitude(), altitude, accuracy);
}
}
gps_updated = true;
tracking_lost = false;
has_valid_position = true;
latest_gps_coord = coord;
latest_gps_coord_accuracy = accuracy;
updateMapWidget();
#endif
}
示例2: data
QVariant TrainModel::data(const QModelIndex& index, int role) const
{
if (index.row() < 0 || index.row() >= trains_.size())
return QVariant();
const Caltrains::Train& train = trains_.at(index.row());
if (role == TrainModel::TrainName) {
QString trainTypeString;
if (train.trainType == Caltrains::Local) {
trainTypeString = "Local";
}
else if (train.trainType == Caltrains::Limited) {
trainTypeString = "Limited";
}
else {
trainTypeString = "Bullet";
}
QString trainNameString = train.trainNumber + " " + trainTypeString;
return QVariant::fromValue(trainNameString);
}
else if (role == TrainModel::TimeRemaining) {
QTime currentTime = QTime::currentTime();
int timeRemaining = (
train.departureTime.msecsSinceStartOfDay() - currentTime.msecsSinceStartOfDay()
) / (60*1000);
if (timeRemaining < 0)
timeRemaining += 60 * 24;
QString timeRemainingText;
if (timeRemaining == 0)
timeRemainingText = "<1 min";
else
timeRemainingText = QString::number(timeRemaining) + " min";
return QVariant::fromValue(timeRemainingText);
}
return QVariant();
}
示例3: loadLRC
bool LyricJson::loadLRC(const QString& path, const QString& musicPath)
{
QFile infile(path);
if (!infile.open(QIODevice::ReadOnly | QIODevice::Text))
{
return false;
}
_song.Clear();
auto settings = Settings::getInstance();
_song.general.maxline = 2; // always 2 ?
while (!infile.atEnd())
{
QByteArray lineByte = infile.readLine();
QString line = QString::fromStdString(lineByte.toStdString()).trimmed();
if (!line.startsWith("["))
{
continue;
}
if (!line.contains("]"))
{
continue;
}
int indexOfClose = line.indexOf("]");
QString controlPart = line.mid(1, indexOfClose - 1).trimmed();
if (controlPart.startsWith("ti:"))
{
_song.info.title = controlPart.right(controlPart.length() - 3); // no trim
}
else if (controlPart.startsWith("au:"))
{
_song.info.author = controlPart.right(controlPart.length() - 3); // no trim
}
else if (controlPart.startsWith("ar:"))
{
_song.info.artist = controlPart.right(controlPart.length() - 3); // no trim
}
else if (controlPart.startsWith("al:"))
{
_song.info.album = controlPart.right(controlPart.length() - 3); // no trim
}
else if (controlPart.startsWith("by:"))
{
_song.info.by = controlPart.right(controlPart.length() - 3); // no trim
}
else if (controlPart.startsWith("offset:"))
{
_song.general.offset = controlPart.right(controlPart.length() - 7).toLongLong();
}
else if (controlPart.at(0).isDigit())
{
QTime beginTime = QTime::fromString(controlPart + "0", "mm:ss.zzz");
qint64 begin = beginTime.msecsSinceStartOfDay();
KJsonSentence sentence;
KJsonWord word;
word.begin = begin;
word.end = begin + settings->maximumDuration(); //std::numeric_limits<qint64>::max();
word.text = line.right(line.length() - indexOfClose - 1);
if (word.text.isEmpty())
{
int thisIndex = _song.lyric.sentencelist.count();
if (thisIndex % _song.general.maxline == 0)
{
// skip
continue;
}
else
{
// move up
// skip multiple whites
if (_song.lyric.sentencelist.last().wordlist.last().begin < 0)
{
continue;
}
else
{
word.end = word.begin + settings->minimumDuration();
}
}
}
if (!_song.lyric.sentencelist.empty())
{
KJsonWord& lastword = _song.lyric.sentencelist.last().wordlist.last();
if (lastword.end - lastword.begin> settings->minimumDuration())
{
lastword.end = begin;// - lastword.begin;
}
}
sentence.wordlist.append(word);
_song.lyric.sentencelist.append(sentence);
}
}
KJsonSong songCopy = _song;
// first generate weak version
//.........这里部分代码省略.........
示例4: qsrand
ClientController::ClientController(QObject *parent)
: QObject{parent}
{
QTime time = QTime::currentTime();
qsrand((uint)(time.elapsed() + time.msecsSinceStartOfDay()));
}
示例5: timeToMSecs
// Converts a date/time value into msecs
static inline qint64 timeToMSecs(const QDate &date, const QTime &time)
{
return ((date.toJulianDay() - JULIAN_DAY_FOR_EPOCH) * MSECS_PER_DAY)
+ time.msecsSinceStartOfDay();
}