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


C++ QDeclarativeListReference::clear方法代码示例

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


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

示例1: 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

示例2: clear

void tst_qdeclarativelistreference::clear()
{
    TestType *tt = new TestType;
    tt->data.append(tt);
    tt->data.append(0);
    tt->data.append(tt);

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

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

    {
    QDeclarativeListReference ref(tt, "data");
    QVERIFY(ref.clear() == true);
    QVERIFY(tt->data.count() == 0);
    delete tt;
    QVERIFY(ref.clear() == false);
    }

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

示例3: qmllistreference_invalid

void tst_qdeclarativelistreference::qmllistreference_invalid()
{
    TestType tt;

    // Invalid
    {
    QDeclarativeListReference r;
    QVERIFY(r.isValid() == false);
    QVERIFY(r.object() == 0);
    QVERIFY(r.listElementType() == 0);
    QVERIFY(r.canAt() == false);
    QVERIFY(r.canClear() == false);
    QVERIFY(r.canCount() == false);
    QVERIFY(r.append(0) == false);
    QVERIFY(r.at(10) == 0);
    QVERIFY(r.clear() == false);
    QVERIFY(r.count() == 0);
    }

    // Non-property
    {
    QDeclarativeListReference r(&tt, "blah");
    QVERIFY(r.isValid() == false);
    QVERIFY(r.object() == 0);
    QVERIFY(r.listElementType() == 0);
    QVERIFY(r.canAt() == false);
    QVERIFY(r.canClear() == false);
    QVERIFY(r.canCount() == false);
    QVERIFY(r.append(0) == false);
    QVERIFY(r.at(10) == 0);
    QVERIFY(r.clear() == false);
    QVERIFY(r.count() == 0);
    }

    // Non-list property
    {
    QDeclarativeListReference r(&tt, "intProperty");
    QVERIFY(r.isValid() == false);
    QVERIFY(r.object() == 0);
    QVERIFY(r.listElementType() == 0);
    QVERIFY(r.canAt() == false);
    QVERIFY(r.canClear() == false);
    QVERIFY(r.canCount() == false);
    QVERIFY(r.append(0) == false);
    QVERIFY(r.at(10) == 0);
    QVERIFY(r.clear() == false);
    QVERIFY(r.count() == 0);
    }
}
开发者ID:husninazer,项目名称:qt,代码行数:49,代码来源:tst_qdeclarativelistreference.cpp

示例4: 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

示例5: 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

示例6: doResetProperty

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


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