当前位置: 首页>>代码示例>>C++>>正文


C++ QDeclarativeProperty::read方法代码示例

本文整理汇总了C++中QDeclarativeProperty::read方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeProperty::read方法的具体用法?C++ QDeclarativeProperty::read怎么用?C++ QDeclarativeProperty::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDeclarativeProperty的用法示例。


在下文中一共展示了QDeclarativeProperty::read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
    }
}
开发者ID:danvratil,项目名称:presquile,代码行数:44,代码来源:pqbaseitem.cpp

示例2: setTarget

void QDeclarativeBehavior::setTarget(const QDeclarativeProperty &property)
{
    Q_D(QDeclarativeBehavior);
    d->property = property;
    d->currentValue = property.read();
    if (d->animation)
        d->animation->setDefaultTarget(property);

    QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
    engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()"));
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:11,代码来源:qdeclarativebehavior.cpp

示例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();
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:16,代码来源:objectnodeinstance.cpp

示例4: setTarget

void QDeclarativeSpringFollow::setTarget(const QDeclarativeProperty &property)
{
    Q_D(QDeclarativeSpringFollow);
    d->property = property;
    d->currentValue = property.read().toReal();
}
开发者ID:,项目名称:,代码行数:6,代码来源:


注:本文中的QDeclarativeProperty::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。