本文整理汇总了C++中QXmlItem::toAtomicValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlItem::toAtomicValue方法的具体用法?C++ QXmlItem::toAtomicValue怎么用?C++ QXmlItem::toAtomicValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlItem
的用法示例。
在下文中一共展示了QXmlItem::toAtomicValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toAtomicValue
void tst_QXmlItem::toAtomicValue() const
{
/* Check default value. */
{
const QXmlItem item;
QVERIFY(item.toAtomicValue().isNull());
}
/* On atomic value. */
{
const QXmlItem item(QVariant(3));
QCOMPARE(item.toAtomicValue(), QVariant(3));
}
/* On a QXmlItem constructed from a null QVariant. */
{
const QXmlItem item((QVariant()));
QVERIFY(item.toAtomicValue().isNull());
}
/* On a QXmlItem constructed from a null QXmlNodeModelIndex. */
{
const QXmlItem item((QXmlNodeModelIndex()));
QVERIFY(item.toAtomicValue().isNull());
}
}
示例2: constCorrectness
/*!
Check that the functions that should be const, are.
*/
void tst_QXmlItem::constCorrectness() const
{
const QXmlItem item;
item.isNull();
item.isNode();
item.isAtomicValue();
item.toAtomicValue();
item.toNodeModelIndex();
}
示例3: qtToXDMType
ItemType::Ptr AtomicValue::qtToXDMType(const QXmlItem &item)
{
Q_ASSERT(!item.isNull());
if(item.isNull())
return ItemType::Ptr();
if(item.isNode())
return BuiltinTypes::node;
Q_ASSERT(item.isAtomicValue());
const QVariant v(item.toAtomicValue());
switch(int(v.type()))
{
case QVariant::Char:
/* Fallthrough. */
case QVariant::String:
/* Fallthrough. */
case QVariant::Url:
return BuiltinTypes::xsString;
case QVariant::Bool:
return BuiltinTypes::xsBoolean;
case QVariant::ByteArray:
return BuiltinTypes::xsBase64Binary;
case QVariant::Int:
/* Fallthrough. */
case QVariant::LongLong:
return BuiltinTypes::xsInteger;
case QVariant::ULongLong:
return BuiltinTypes::xsUnsignedLong;
case QVariant::Date:
return BuiltinTypes::xsDate;
case QVariant::DateTime:
/* Fallthrough. */
case QVariant::Time:
return BuiltinTypes::xsDateTime;
case QMetaType::Float:
return BuiltinTypes::xsFloat;
case QVariant::Double:
return BuiltinTypes::xsDouble;
default:
return ItemType::Ptr();
}
}
示例4: Load
//Load the asset from the specified file
bool GMAsset_Sprite::Load(const QFileInfo &file)
{
this->GMAsset::Load(file);
QFile spriteFile(file.absoluteFilePath());
if (!spriteFile.exists()) return false; //File does not exist
if (!spriteFile.open(QIODevice::ReadOnly | QIODevice::Text))
return false; //Failed to open the file
QXmlQuery query;
QXmlResultItems result;
QXmlItem item;
query.setFocus(&spriteFile);
//Type of sprite
query.setQuery("sprite/type/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetType(item.toAtomicValue().toInt());
}
QPoint origin;
//X Origin
query.setQuery("sprite/xorig/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
origin.setX(item.toAtomicValue().toInt());
}
//Y Origin
query.setQuery("sprite/yorigin/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
origin.setY(item.toAtomicValue().toInt());
}
SetOrigin(origin);
//Collision Kind
query.setQuery("sprite/colkind/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetCollisionKind((CollisionKind)item.toAtomicValue().toInt());
}
//Color Tolerance
query.setQuery("sprite/coltolerance/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetColTolerance(item.toAtomicValue().toInt());
}
//Seprate Masks?
query.setQuery("sprite/sepmasks/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetSepMasks(item.toAtomicValue().toBool());
}
//Bounding Box Mode
query.setQuery("sprite/bboxmode/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
SetBboxMode((BoundingBoxMode)item.toAtomicValue().toInt());
}
QRect bbox; //Bounding box
//Bounding Box Left
query.setQuery("sprite/bbox_left/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
bbox.setLeft(item.toAtomicValue().toInt());
}
//Bounding Box Right
query.setQuery("sprite/bbox_right/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
bbox.setRight(item.toAtomicValue().toInt());
}
//Bounding Box Top
query.setQuery("sprite/bbox_top/string()");
query.evaluateTo(&result);
item = result.next();
if (item.isAtomicValue()) { //Make sure the item is an atomic value (ie, the node string was returned)
bbox.setTop(item.toAtomicValue().toInt());
}
//Bounding Box Bottom
query.setQuery("sprite/bbox_bottom/string()");
query.evaluateTo(&result);
item = result.next();
//.........这里部分代码省略.........