Make sure your function is Q_INVOKABLE or is a slot. also take care .pragme library is not possible with javascript and object from c++ access
> On Nov 27, 2015, at 7:43 PM, Jason H <[email protected]> wrote: > > Per http://doc.qt.io/qt-5/qtqml-javascript-imports.html > > I am trying to in a JS file, import a class I made and exposed to QML via > > hash.h: > class Hash :public QObject { > Q_OBJECT > ... > QString sha1(QString str); > } > > main(): > qmlRegisterType<Hash>("MyLib", 1, 0, "Hash"); > > myfile.js: > .import MyLib 1.0 as MyLib > > function myFunc(obj) { > return MyLib.Hash.sha1(JSON.stringify(obj)); > } > > but what I get when I call it is: > qml: Parse Error: TypeError: Property 'sha1' of object [object Object] is not > a function > > What am I doing wrong? > JSON.Stringify-ing the MyLib or MyLib.Hash returns {} > > > > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
