本文整理汇总了C++中QDeclarativeProperty::name方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeProperty::name方法的具体用法?C++ QDeclarativeProperty::name怎么用?C++ QDeclarativeProperty::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeProperty
的用法示例。
在下文中一共展示了QDeclarativeProperty::name方法的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: removeObjectFromList
static void removeObjectFromList(const QDeclarativeProperty &property, QObject *objectToBeRemoved, QDeclarativeEngine * engine)
{
QDeclarativeListReference listReference(property.object(), property.name().toLatin1(), engine);
if (!hasFullImplementedListInterface(listReference)) {
qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!";
return;
}
int count = listReference.count();
QObjectList objectList;
for(int i = 0; i < count; i ++) {
QObject *listItem = listReference.at(i);
if (listItem != objectToBeRemoved)
objectList.append(listItem);
}
listReference.clear();
foreach(QObject *object, objectList)
listReference.append(object);
}
示例3: deleteObjectsInList
void ObjectNodeInstance::deleteObjectsInList(const QDeclarativeProperty &property)
{
QObjectList objectList;
QDeclarativeListReference list = qvariant_cast<QDeclarativeListReference>(property.read());
if (!hasFullImplementedListInterface(list)) {
qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!";
return;
}
for(int i = 0; i < list.count(); i++) {
objectList += list.at(i);
}
list.clear();
}