Return collection from plugin to script environment

I need to return a collection from an SDK plugin, let's say a QList<DzNode*>.    This documentation appears to be exactly what I need : http://doc.qt.io/qt-4.8/qscriptengine.html#qScriptRegisterSequenceMetaType

How do I get a pointer to the QScriptEngine in use by the Daz app though?    If I just create my own it doesn't work, so I assume Daz has one that I need to use instead.   

 

Thanks!

 

Comments

  • rbtwhizrbtwhiz Posts: 2,171

    We do not provide access to the script engine itself. What you can do, however, is create a public slot on your class that returns a QVariantList. This will be seen by the script environment as an Array of objects of whatever type you put into it (assuming said type is registered).

    QVariantList MyClass::myPublicSlot(){	DzNodeList nodeList; // typedef for QList&lt;DzNode *&gt;	QVariantList scriptArray;	DzNodeListIterator nodeIter( nodeList );	while( nodeIter.hasNext() )	{		scriptArray &lt;&lt; QVariant::fromValue&lt;QObject*&gt;( nodeIter.next() );	}	return scriptArray;}

    -Rob

  • shoei321shoei321 Posts: 113

    Thanks again Rob, that was what I needed.

     

Sign In or Register to comment.