本文整理汇总了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);
}
}
示例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());
}
}
示例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());
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例8: hasFullImplementedListInterface
static bool hasFullImplementedListInterface(const QQmlListReference &list)
{
return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
}
示例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;
}
}