Since Qt
5.5 is actual, QtScript
is deprecated. The replacement is Qt
QML with QJSEngine
. Now, I will rewrite my project to the new engine. I have some Classes like:
class Node : public QObject
{
Q_OBJECT
Q_PROPERTY(QList<Node*> childs READ childs)
public:
inline QList<Node*> childs() {
return childsByID.values();
}
Q_INVOKABLE QList<Node*> someChilds(QString filter);
Q_INVOKABLE Node* makeChild(/*some args*/); // returns maybe 0.
private:
Node(Node* parent);
QHash<QString, Node*> childsByID;
QHash<QString, Node*> childsByXYZ;
};
Q_DECLARE_METATYPE(Node*)
Q_DECLARE_METATYPE(QList<Node*>)
and in QtScript
registered this with:
qScriptRegisterMetaType(&engine, nodeToScriptValue, nodeFromScriptValue);
qScriptRegisterSequenceMetaType<QList<Node*>>(&engine);
In the new QJSEngine I register the Node with qmlRegisterUncreatableType. But, I don't find a way to register the QList.
Knows anybody the right way ?