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