本文整理汇总了C++中QStringRef::toUInt方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::toUInt方法的具体用法?C++ QStringRef::toUInt怎么用?C++ QStringRef::toUInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::toUInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
QList<UpdateInfo> * UpdatesProcessor::readUpdates(QList<UpdateInfo> *updates, QXmlStreamReader *xmlReader)
{
if (xmlReader->readNextStartElement()) {
while (xmlReader->name() == "update") {
UpdateInfo updateInfo;
while(xmlReader->readNextStartElement()) {
if (xmlReader->name() == "id") {
xmlReader->readNext();
QStringRef id = xmlReader->text();
updateInfo.id = id.toUInt();
} else if (xmlReader->name() == "url") {
xmlReader->readNext();
updateInfo.url = xmlReader->text().toString();
} else if (xmlReader->name() == "title") {
xmlReader->readNext();
updateInfo.title = xmlReader->text().toString();
} else if (xmlReader->name() == "text") {
xmlReader->readNext();
updateInfo.text = xmlReader->text().toString();
} else if (xmlReader->name() == "softwareVersion") {
xmlReader->readNext();
updateInfo.softwareVersion = xmlReader->text().toString();
} else if (xmlReader->name() == "firmwareVersion") {
xmlReader->readNext();
updateInfo.firmwareVersion = xmlReader->text().toString();
} else if (xmlReader->name() == "update") {
break;
} else {
xmlReader->skipCurrentElement();
}
xmlReader->skipCurrentElement();
}
// add updates with defined id only
if(updateInfo.id > 0)
updates->append(updateInfo);
}
}
return updates;
}
示例2: printWithFormat
void Console::printWithFormat(const QString& str, const QTextCharFormat& fmt)
{
const QString escape = QStringLiteral("\x1b[");
QTextCursor cur(document()->lastBlock());
cur.movePosition((QTextCursor::StartOfBlock));
cur.setCharFormat(fmt);
int startIndex = 0;
while(true) {
int escapeIndex = str.indexOf(escape, startIndex);
if (escapeIndex == -1) {
// no more escape codes found, output rest of string
cur.insertText(str.mid(startIndex, str.length()-startIndex));
break;
}
// escape code found, output everything up to it
cur.insertText(str.mid(startIndex, escapeIndex-startIndex));
// look for 'm', the termination character for graphic escape codes
int termIndex = str.indexOf('m', escapeIndex);
// if didn't find termination code, jump over escape sequence and loop
if (termIndex == -1) {
startIndex = escapeIndex + escape.size();
continue;
}
// found termination code, set startIndex for next loop iteration
startIndex = termIndex + 1;
// extract payload: should be one or more numbers separated by semicolons
int formatCodeStart = escapeIndex + escape.size();
// read format codes
while (formatCodeStart < termIndex) {
// Look for digits
int formatCodeEnd = formatCodeStart;
while (str[formatCodeEnd].isDigit() && formatCodeEnd < termIndex) {
formatCodeEnd++;
}
// abort if we overran the escape sequence
if (formatCodeEnd > termIndex) break;
// convert to number
QStringRef formatCodeString = str.midRef(formatCodeStart, formatCodeEnd-formatCodeStart);
bool ok = false;
int formatCode = formatCodeString.toUInt(&ok);
if (!ok) break;
applyFormatCode(cur, formatCode);
// if a semicolon follows, loop again, otherwise we're done
if (str[formatCodeEnd] != ';') break;
formatCodeStart = formatCodeEnd + 1;
}
}
if (!str.endsWith("\n")) {
cur.insertBlock();
}
setTextCursor(cur);
moveToEndOfCommandLine();
}