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


C++ QDeclarativeListReference类代码示例

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


在下文中一共展示了QDeclarativeListReference类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QVERIFY

void tst_qdeclarativelistreference::canCount()
{
    TestType *tt = new TestType;

    {
    QDeclarativeListReference ref;
    QVERIFY(ref.canCount() == false);
    }

    {
    QDeclarativeListReference ref(tt, "blah");
    QVERIFY(ref.canCount() == false);
    }

    {
    QDeclarativeListReference ref(tt, "data");
    QVERIFY(ref.canCount() == true);
    delete tt;
    QVERIFY(ref.canCount() == false);
    }

    {
    TestType tt;
    tt.property.count = 0;
    QDeclarativeListReference ref(&tt, "data");
    QVERIFY(ref.canCount() == false);
    }
}
开发者ID:husninazer,项目名称:qt,代码行数:28,代码来源:tst_qdeclarativelistreference.cpp

示例2: prop

void tst_qdeclarativelistreference::qmlmetaproperty()
{
    TestType tt;
    tt.data.append(&tt);
    tt.data.append(0);
    tt.data.append(&tt);

    QDeclarativeProperty prop(&tt, QLatin1String("data"));
    QVariant v = prop.read();
    QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
    QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
    QVERIFY(ref.count() == 3);
    QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
}
开发者ID:husninazer,项目名称:qt,代码行数:14,代码来源:tst_qdeclarativelistreference.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: outStream

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

示例5: property

void ObjectNodeInstance::doResetProperty(const QString &propertyName)
{
    m_modelAbstractPropertyHash.remove(propertyName);

    QDeclarativeProperty property(object(), propertyName, context());

    if (!property.isValid())
        return;

    QVariant oldValue = property.read();
    if (oldValue.type() == QVariant::Url) {
        QUrl url = oldValue.toUrl();
        QString path = url.toLocalFile();
        if (QFileInfo(path).exists() && nodeInstanceView())
            nodeInstanceView()->removeFilePropertyFromFileSystemWatcher(object(), propertyName, path);
    }


    QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::binding(property);
    if (binding) {
        binding->setEnabled(false, 0);
        binding->destroy();
    }

    if (property.isResettable()) {
        property.reset();
    } else if (property.propertyTypeCategory() == QDeclarativeProperty::List) {
        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;
        }

        list.clear();
    } else if (property.isWritable()) {
        if (property.read() == resetValue(propertyName))
            return;
        property.write(resetValue(propertyName));
    }
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:41,代码来源:objectnodeinstance.cpp

示例6: component

void tst_qdeclarativelistreference::engineTypes()
{
    QDeclarativeEngine engine;
    QDeclarativeComponent component(&engine, TEST_FILE("engineTypes.qml"));

    QObject *o = component.create();
    QVERIFY(o);

    QDeclarativeProperty p1(o, QLatin1String("myList"));
    QVERIFY(p1.propertyTypeCategory() == QDeclarativeProperty::Normal);

    QDeclarativeProperty p2(o, QLatin1String("myList"), engine.rootContext());
    QVERIFY(p2.propertyTypeCategory() == QDeclarativeProperty::List);
    QVariant v = p2.read();
    QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
    QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
    QVERIFY(ref.count() == 2);
    QVERIFY(ref.listElementType());
    QVERIFY(ref.listElementType() != &QObject::staticMetaObject);

    delete o;
}
开发者ID:husninazer,项目名称:qt,代码行数:22,代码来源:tst_qdeclarativelistreference.cpp

示例7: removeObjectFromListProperty

bool removeObjectFromListProperty(QDeclarativeListReference &fromList, QObject *object)
{
    QList<QObject *> tmpList;
    int i;

    if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
        return false;

    for (i=0; i<fromList.count(); ++i)
        if (object != fromList.at(i))
            tmpList << fromList.at(i);

    fromList.clear();

    foreach (QObject *item, tmpList)
        fromList.append(item);

    return true;
}
开发者ID:pcacjr,项目名称:qt-creator,代码行数:19,代码来源:qdeclarativeviewinspector.cpp

示例8: hasFullImplementedListInterface

static bool hasFullImplementedListInterface(const QDeclarativeListReference &list)
{

#if QT_VERSION<0x050000
    return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
#else
    return list.isChangeable();
#endif
}
开发者ID:bakaiadam,项目名称:collaborative_qt_creator,代码行数:9,代码来源:objectnodeinstance.cpp

示例9: insertObjectInListProperty

bool insertObjectInListProperty(QDeclarativeListReference &fromList, int position, QObject *object)
{
    QList<QObject *> tmpList;
    int i;

    if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
        return false;

    if (position == fromList.count()) {
        fromList.append(object);
        return true;
    }

    for (i=0; i<fromList.count(); ++i)
        tmpList << fromList.at(i);

    fromList.clear();
    for (i=0; i<position; ++i)
        fromList.append(tmpList.at(i));

    fromList.append(object);
    for (; i<tmpList.count(); ++i)
        fromList.append(tmpList.at(i));

    return true;
}
开发者ID:pcacjr,项目名称:qt-creator,代码行数:26,代码来源:qdeclarativeviewinspector.cpp

示例10: hasFullImplementedListInterface

static bool hasFullImplementedListInterface(const QDeclarativeListReference &list)
{
    return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:4,代码来源:objectnodeinstance.cpp


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