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


C++ QQmlListReference类代码示例

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


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

示例1: QVERIFY

void tst_qqmllistreference::isManipulable()
{
    TestType *tt = new TestType;

    {
    QQmlListReference ref;
    QVERIFY(ref.isManipulable() == false);
    }

    {
    QQmlListReference ref(tt, "blah");
    QVERIFY(ref.isManipulable() == false);
    }

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

    {
    TestType tt;
    tt.property.count = 0;
    QQmlListReference ref(&tt, "data");
    QVERIFY(ref.isManipulable() == false);
    }
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:28,代码来源:tst_qqmllistreference.cpp

示例2: QVERIFY

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

    {
    QQmlListReference ref;
    QVERIFY(!ref.canCount());
    }

    {
    QQmlListReference ref(tt, "blah");
    QVERIFY(!ref.canCount());
    }

    {
    QQmlListReference ref(tt, "data");
    QVERIFY(ref.canCount());
    delete tt;
    QVERIFY(!ref.canCount());
    }

    {
    TestType tt;
    tt.property.count = 0;
    QQmlListReference ref(&tt, "data");
    QVERIFY(!ref.canCount());
    }
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:28,代码来源:tst_qqmllistreference.cpp

示例3: property

void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty)
{
    QQmlProperty property(newParent, QString::fromUtf8(newParentProperty), context());

    if (object)
        object->setParent(newParent);

    if (isList(property)) {
        QQmlListReference list = qvariant_cast<QQmlListReference>(property.read());

        if (!QmlPrivateGate::hasFullImplementedListInterface(list)) {
            qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!";
            return;
        }

        list.append(object);
    } else if (isObject(property)) {
        property.write(objectToVariant(object));

        if (QQuickItem *item = qobject_cast<QQuickItem *>(object))
            if (QQuickItem *newParentItem = qobject_cast<QQuickItem *>(newParent))
                item->setParentItem(newParentItem);
    }

    Q_ASSERT(objectToVariant(object).isValid());
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:26,代码来源:objectnodeinstance.cpp

示例4: prop

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

    QQmlProperty prop(&tt, QLatin1String("data"));
    QVariant v = prop.read();
    QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>());
    QQmlListReference ref = qvariant_cast<QQmlListReference>(v);
    QVERIFY(ref.count() == 3);
    QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:14,代码来源:tst_qqmllistreference.cpp

示例5: deleteObjectsInList

void ObjectNodeInstance::deleteObjectsInList(const QQmlProperty &property)
{
    QObjectList objectList;
    QQmlListReference list = qvariant_cast<QQmlListReference>(property.read());

    if (!QmlPrivateGate::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:qtproject,项目名称:qt-creator,代码行数:16,代码来源:objectnodeinstance.cpp

示例6: qDebug

bool    DataVizAdapter::bars3DHasSeries(QBar3DSeries* series)
{
    qDebug() << "DataVizAdapter::bars3DHasSeries(): series=" << series << "\tgetBars3D()=" << getBars3D();
    bool hasSeries{false};
    if ( getBars3D() != nullptr ) {
        QQmlProperty seriesListQmlProperty(getBars3D(), "seriesList");
        if ( seriesListQmlProperty.isValid() ) {
            QQmlListReference seriesList = qvariant_cast<QQmlListReference>( seriesListQmlProperty.read() );
            if (seriesList.isValid())
                for ( int s = 0; s < seriesList.count(); s++ )
                    if ( seriesList.at(s) == series ) {
                        hasSeries = true;
                        break;
                    }
        }
    }
    return hasSeries;
}
开发者ID:cneben,项目名称:QuickProperties,代码行数:18,代码来源:qpsDataVizAdapter.cpp

示例7: component

void tst_qqmllistreference::engineTypes()
{
    QQmlEngine engine;
    QQmlComponent component(&engine, testFileUrl("engineTypes.qml"));

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

    QQmlProperty p1(o, QLatin1String("myList"));
    QVERIFY(p1.propertyTypeCategory() == QQmlProperty::List);

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

    delete o;
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:22,代码来源:tst_qqmllistreference.cpp

示例8: hasFullImplementedListInterface

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

示例9: packDataValue


//.........这里部分代码省略.........
        value->dataType = DTFloat64;
        *(double*)(value->data) = qvar->toDouble();
        break;
    case QMetaType::Float:
        value->dataType = DTFloat32;
        *(float*)(value->data) = qvar->toFloat();
        break;
    case QMetaType::QColor:
        value->dataType = DTColor;
        *(unsigned int*)(value->data) = qvar->value<QColor>().rgba();
        break;
    case QMetaType::QVariantList:
        {
            QVariantList varlist = qvar->toList();
            int len = varlist.size();
            DataValue *dvlist = (DataValue *) malloc(sizeof(DataValue) * len);
            for (int i = 0; i < len; i++) {
                packDataValue((void*)&varlist.at(i), &dvlist[i]);
            }
            value->dataType = DTValueList;
            value->len = len;
            *(DataValue**)(value->data) = dvlist;
        }
        break;
    case QMetaType::QVariantMap:
        {
            QVariantMap varmap = qvar->toMap();
            int len = varmap.size() * 2;
            DataValue *dvlist = (DataValue *) malloc(sizeof(DataValue) * len);
            QMapIterator<QString, QVariant> it(varmap);
            for (int i = 0; i < len; i += 2) {
                if (!it.hasNext()) {
                    panicf("QVariantMap mutated during iteration");
                }
                it.next();
                QVariant key = it.key();
                QVariant val = it.value();
                packDataValue((void*)&key, &dvlist[i]);
                packDataValue((void*)&val, &dvlist[i+1]);
            }
            value->dataType = DTValueMap;
            value->len = len;
            *(DataValue**)(value->data) = dvlist;
        }
        break;
    default:
        if (qvar->type() == (int)QMetaType::QObjectStar || qvar->canConvert<QObject *>()) {
            QObject *qobject = qvar->value<QObject *>();
            GoValue *goValue = dynamic_cast<GoValue *>(qobject);
            if (goValue) {
                value->dataType = DTGoAddr;
                *(void **)(value->data) = goValue->addr;
                break;
            }
            GoPaintedValue *goPaintedValue = dynamic_cast<GoPaintedValue *>(qobject);
            if (goPaintedValue) {
                value->dataType = DTGoAddr;
                *(void **)(value->data) = goPaintedValue->addr;
                break;
            }
            value->dataType = DTObject;
            *(void **)(value->data) = qobject;
            break;
        }
        {
            QQmlListReference ref = qvar->value<QQmlListReference>();
            if (ref.isValid() && ref.canCount() && ref.canAt()) {
                int len = ref.count();
                DataValue *dvlist = (DataValue *) malloc(sizeof(DataValue) * len);
                QVariant elem;
                for (int i = 0; i < len; i++) {
                    elem.setValue(ref.at(i));
                    packDataValue(&elem, &dvlist[i]);
                }
                value->dataType = DTValueList;
                value->len = len;
                *(DataValue**)(value->data) = dvlist;
                break;
            }
        }
        if (qstrncmp(qvar->typeName(), "QQmlListProperty<", 17) == 0) {
            QQmlListProperty<QObject> *list = reinterpret_cast<QQmlListProperty<QObject>*>(qvar->data());
            if (list->count && list->at) {
                int len = list->count(list);
                DataValue *dvlist = (DataValue *) malloc(sizeof(DataValue) * len);
                QVariant elem;
                for (int i = 0; i < len; i++) {
                    elem.setValue(list->at(list, i));
                    packDataValue(&elem, &dvlist[i]);
                }
                value->dataType = DTValueList;
                value->len = len;
                *(DataValue**)(value->data) = dvlist;
                break;
            }
        }
        panicf("unsupported variant type: %d (%s)", qvar->type(), qvar->typeName());
        break;
    }
}
开发者ID:chai2010,项目名称:qml,代码行数:101,代码来源:goqml.cpp


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