本文整理汇总了C++中QContactDetail::removeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QContactDetail::removeValue方法的具体用法?C++ QContactDetail::removeValue怎么用?C++ QContactDetail::removeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContactDetail
的用法示例。
在下文中一共展示了QContactDetail::removeValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: values
//.........这里部分代码省略.........
QCOMPARE(p.value<QString>("string"), QString("This is a string"));
QCOMPARE(p.value<QString>("date"), d.toString(Qt::ISODate));
QCOMPARE(p.value<QString>("datetime"), dt.toString(Qt::ISODate));
QCOMPARE(p.value<QString>("int"), QString("6"));
QCOMPARE(p.value<QString>("stringdate"), d.toString(Qt::ISODate));
QCOMPARE(p.value<QString>("stringdatetime"), dt.toString(Qt::ISODate));
QCOMPARE(p.value<QString>("stringint"), QString("123"));
/* Now individual original types */
QCOMPARE(p.value<QDate>("date"), d);
QCOMPARE(p.value<QDateTime>("datetime"), dt);
QCOMPARE(p.value<int>("int"), 6);
/* Now cross types that should fail */
QCOMPARE(p.value<QDate>("string"), id);
QCOMPARE(p.value<QDate>("int"), id);
QCOMPARE(p.value<QDate>("stringint"), id);
QCOMPARE(p.value<QDateTime>("string"), idt);
QCOMPARE(p.value<QDateTime>("int"), idt);
QCOMPARE(p.value<QDateTime>("stringint"), idt);
QCOMPARE(p.value<int>("date"), 0);
QCOMPARE(p.value<int>("datetime"), 0);
QCOMPARE(p.value<int>("string"), 0);
QCOMPARE(p.value<int>("stringdate"), 0);
QCOMPARE(p.value<int>("stringdatetime"), 0);
/* Cross types that should work.. */
QCOMPARE(p.value<int>("stringint"), 123);
QCOMPARE(p.value<QDate>("stringdate"), d);
QCOMPARE(p.value<QDateTime>("stringdatetime"), dt);
QCOMPARE(p.value<QDate>("datetime"), d);
QCOMPARE(p.value<QDate>("stringdatetime"), d);
QCOMPARE(p.value<QDateTime>("date"), ddt);
QCOMPARE(p.value<QDateTime>("stringdate"), ddt);
/* Reset again */
values = p.variantValues();
keys = values.keys();
foreach (const QString& key, keys)
QVERIFY(p.setValue(key, QVariant()));
QCOMPARE(p.variantValues(), emptyValues);
/* Check that we can add a null variant */
//QVERIFY(p.setValue("nullvariant", QVariant()));
//QVERIFY(p.hasValue("nullvariant"));
//QCOMPARE(p.value("nullvariant"), QString());
//QCOMPARE(p.variantValue("nullvariant"), QVariant());
//QVERIFY(p.removeValue("nullvariant"));
//QVERIFY(p.values().count() == 0);
/* Check that adding a value, then setting it to null updates it */
//QVERIFY(p.setValue("string", QString("string value")));
//QCOMPARE(p.values().count(), 1);
//QCOMPARE(p.value("string"), QString("string value"));
//QVERIFY(p.setValue("string", QVariant()));
//QCOMPARE(p.values().count(), 1);
//QVERIFY(p.hasValue("string"));
//QVERIFY(p.removeValue("string"));
//QCOMPARE(p.values().count(), 0);
/* See if adding a null QString triggers the same behaviour */
//QVERIFY(p.setValue("string", QString("string value")));
//QCOMPARE(p.values().count(), 1);
//QCOMPARE(p.value("string"), QString("string value"));
//QVERIFY(p.setValue("string", QString()));
//QCOMPARE(p.values().count(), 1);
//QVERIFY(p.hasValue("string"));
//QVERIFY(p.removeValue("string"));
//QCOMPARE(p.values().count(), 0);
/* Check adding a null value removes the field */
p.setValue("string", "stringvalue");
QVERIFY(p.variantValues().contains("string"));
QVERIFY(p.value("string") == QString("stringvalue"));
p.setValue("string", QVariant());
QVERIFY(!p.variantValues().contains("string"));
/* Check adding a field whose value is an empty string */
p.setValue("string", "");
QVERIFY(p.variantValues().contains("string"));
QVERIFY(p.value("string") == QString(""));
/* Check accessing a missing value */
QCOMPARE(p.value("nonexistent"), QString());
QVERIFY(p.setValue("nonexistent", "changed my mind"));
QCOMPARE(p.value("nonexistent"), QString("changed my mind"));
/* Check removing a missing value */
QVERIFY(!p.removeValue("does not exist"));
QVERIFY(!p.removeValue(QLatin1String("does not exist")));
QVERIFY(!p.removeValue(QContactAddress::FieldCountry));
p.setValue("stringint", "555");
p.setValue(QContactPhoneNumber::FieldNumber, "1234");
/* Check removing a real value */
QVERIFY(p.removeValue("string"));
QVERIFY(p.removeValue(QLatin1String("stringint")));
QVERIFY(p.removeValue(QContactPhoneNumber::FieldNumber));
}