本文整理汇总了C++中QQmlListReference::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlListReference::clear方法的具体用法?C++ QQmlListReference::clear怎么用?C++ QQmlListReference::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlListReference
的用法示例。
在下文中一共展示了QQmlListReference::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clear
void tst_qqmllistreference::clear()
{
TestType *tt = new TestType;
tt->data.append(tt);
tt->data.append(0);
tt->data.append(tt);
{
QQmlListReference ref;
QVERIFY(ref.clear() == false);
}
{
QQmlListReference ref(tt, "blah");
QVERIFY(ref.clear() == false);
}
{
QQmlListReference ref(tt, "data");
QVERIFY(ref.clear() == true);
QVERIFY(tt->data.count() == 0);
delete tt;
QVERIFY(ref.clear() == false);
}
{
TestType tt;
tt.property.clear = 0;
QQmlListReference ref(&tt, "data");
QVERIFY(ref.clear() == false);
}
}
示例2: qmllistreference_invalid
void tst_qqmllistreference::qmllistreference_invalid()
{
TestType tt;
// Invalid
{
QQmlListReference 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);
QVERIFY(r.isReadable() == false);
QVERIFY(r.isManipulable() == false);
}
// Non-property
{
QQmlListReference 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);
QVERIFY(r.isReadable() == false);
QVERIFY(r.isManipulable() == false);
}
// Non-list property
{
QQmlListReference 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);
QVERIFY(r.isReadable() == false);
QVERIFY(r.isManipulable() == false);
}
}
示例3: 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();
}