On Friday, June 14, 2013 16:43:12 Sandro Andrade wrote:
> Am I missing something ?

The QML engine doesn't use the QVariant API for accessing things in a 
QVariant. So capabilities you have when using QVariant/Q_PROPERTY are not 
available in QML. This is probably fixable, but I'm not sure it's understood 
by the people who know QML well enough to fix it.

  QGuiApplication app(argc, argv);

  QList<QUmlObject*> l;
  QUmlObject *o1 = new QUmlObject;
  Q_SET_OBJECT_NAME(o1);
  l.push_back(o1);
  QUmlObject *o2 = new QUmlObject;
  Q_SET_OBJECT_NAME(o2);
  l.push_back(o2);

  QVariant v = QVariant::fromValue(l);

  if (v.canConvert<QVariantList>()) {
      QSequentialIterable seqIter = v.value<QSequentialIterable>();
      qDebug() << seqIter.size();

      foreach(const QVariant &item, seqIter) {
        qDebug() << item;
      }
  }

  QQmlEngine engine;
  engine.rootContext()->setContextProperty("_objList", v);
  QQmlComponent component(&engine);
  component.setData("import QtQuick 2.0\nItem { Component.onCompleted : 
console.log(_objList), _objList.length() }", QUrl());
  component.create();


2 
QVariant(QUmlObject*, QUmlObject(0xa05920, name = "o1") ) 
QVariant(QUmlObject*, QUmlObject(0xa11190, name = "o2") ) 
QVariant(QList<QUmlObject*>)
<Unknown File>: TypeError: Object [object Object] has no method 'length'




Thanks,

-- 
Stephen Kelly <stephen.ke...@kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to