本文整理汇总了C++中QDeclarativeProperty::propertyTypeCategory方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeProperty::propertyTypeCategory方法的具体用法?C++ QDeclarativeProperty::propertyTypeCategory怎么用?C++ QDeclarativeProperty::propertyTypeCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeProperty
的用法示例。
在下文中一共展示了QDeclarativeProperty::propertyTypeCategory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serializeProperty
void PQBaseItem::serializeProperty(QTextStream &stream, const QDeclarativeProperty &property, unsigned indentSize) const
{
QString str;
QTextStream outStream(&str);
if (property.propertyTypeCategory() == QDeclarativeProperty::Normal) { // Normal value property
const int propertyType = property.propertyType();
const QString propertyValue = property.read().toString();
if (propertyType >= QVariant::Bool && propertyType <= QVariant::Double) { // Numerical, unquoted values
outStream << propertyValue;
} else {
if (!propertyValue.isEmpty()) {
QString value = propertyValue;
value.replace(QLatin1Char('\\'), QLatin1String("\\\\")) // escape backslashes in rich text
.replace(QLatin1Char('"'), QLatin1String("\\\"")); // escape quotes
value = QLatin1Char('"') % value % QLatin1Char('"');
outStream << value;
}
}
} else if (property.propertyTypeCategory() == QDeclarativeProperty::Object) { // Complex Object type
const QVariant variantValue = property.read();
if (variantValue.isValid() && !variantValue.isNull()) {
serializeObject(outStream, variantValue.value<QObject *>(), indentSize);
}
} else if (property.propertyTypeCategory() == QDeclarativeProperty::List) { // List of objects
const QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(property.read());
outStream << QLatin1Char('[') << endl;
for (int itemIndex = 0, c = list.count(); itemIndex < c; ++itemIndex) {
QObject *item = list.at(itemIndex);
serializeObject(outStream, item, indentSize+1);
if (itemIndex + 1 != list.count()) {
outStream << QLatin1Char(','); // separator
}
outStream << endl;
}
outStream << PQSerializer::indentStep().repeated(indentSize) << QLatin1String("]"); // close list
}
if (!str.isEmpty()) {
stream << PQSerializer::indentStep().repeated(indentSize)
<< property.name() << QLatin1String(": ") << str
<< endl;
}
}
示例2: isObject
static bool isObject(const QDeclarativeProperty &property)
{
return property.propertyTypeCategory() == QDeclarativeProperty::Object;
}
示例3: isObject
static bool isObject(const QDeclarativeProperty &property)
{
return (property.propertyTypeCategory() == QDeclarativeProperty::Object) ||
//QVariant can also store QObjects. Lets trust our model.
(QLatin1String(property.propertyTypeName()) == QLatin1String("QVariant"));
}