QVectorQML/Javascript 内で使用するにはどうすればよいですか? 例:
C++:
QMLで使用するカスタムクラス。QVectorクラスには、登録されたものを返す関数が含まれていますElementType
class CustomType : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE QVector<ElementType*> getElements();
//.....
}
//.........
qmlRegisterType<CustomType>("CustomComponents", 1, 0, "CustomType");
qmlRegisterType<ElementType>("CustomComponents", 1, 0, "ElementType");
qRegisterMetaType<ElementType*>("ElementType*");
QML:
QML コードはクラス (カスタム) のインスタンスを受け取り、要素のCustomType取得を試み、そのプロパティを読み取ります。QVector<ElementType*>しかし、QML はQVector型を認識できません。
//.......
function(){
var elements = custom.getElements()
elements[0].property //?
}