本文整理汇总了C++中QDeclarativeListReference::append方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeListReference::append方法的具体用法?C++ QDeclarativeListReference::append怎么用?C++ QDeclarativeListReference::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeListReference
的用法示例。
在下文中一共展示了QDeclarativeListReference::append方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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);
}
}
示例3: 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;
}
示例4: addToNewProperty
void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, const QString &newParentProperty)
{
QDeclarativeProperty property(newParent, newParentProperty, context());
if (isList(property)) {
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.append(object);
} else if (isObject(property)) {
property.write(objectToVariant(object));
}
object->setParent(newParent);
Q_ASSERT(objectToVariant(object).isValid());
}
示例5: append
void tst_qdeclarativelistreference::append()
{
TestType *tt = new TestType;
QObject object;
{
QDeclarativeListReference ref;
QVERIFY(ref.append(tt) == false);
}
{
QDeclarativeListReference ref(tt, "blah");
QVERIFY(ref.append(tt) == false);
}
{
QDeclarativeListReference ref(tt, "data");
QVERIFY(ref.append(tt) == true);
QVERIFY(tt->data.count() == 1);
QVERIFY(tt->data.at(0) == tt);
QVERIFY(ref.append(&object) == false);
QVERIFY(tt->data.count() == 1);
QVERIFY(tt->data.at(0) == tt);
QVERIFY(ref.append(0) == true);
QVERIFY(tt->data.count() == 2);
QVERIFY(tt->data.at(0) == tt);
QVERIFY(tt->data.at(1) == 0);
delete tt;
QVERIFY(ref.append(0) == false);
}
{
TestType tt;
tt.property.append = 0;
QDeclarativeListReference ref(&tt, "data");
QVERIFY(ref.append(&tt) == false);
}
}