---- On Mon, 18 Apr 2016 11:06:59 -0400 Jason H <[email protected]> wrote ---- 
 > ttps://forum.qt.io/topic/52306/qt-5-5-qt-script-deprecated-what-is-replacement/12
 > > 
 > > I saw this thread, but it did not seem to offer a clear detail other than 
 > > to use QJSEngine and QJSValue directly.  Specifically I use 
 > > qScriptRegisterMetaType very heavy to add custom types.  I know if I am 
 > > using QML I can use qmlRegisterType<T>(uri, 1, 0, "T") but it only makes 
 > > the type available via the declarative components.  It also requires the 
 > > object be a QObject which means sharing pointers.  There is also a problem 
 > > inside of the Javascript.  It is very cumbersome to dynamically create 
 > > these types.  I understand I am fighting QML, but my design is not as 
 > > declarative as it is creating objects that can be passed back into C++.   
 > > I may be missing something though.
 > > 
 > > As an example below with a type called MyStruct:
 > > 
 > > ... Qt Script...
 > > 
 > > var myStruct = new MyStruct();
 > > myStruct.x = 10;
 > > 
 > >  ....QML...
 > > 
 > > var myStruct;
 > > var component = Qt.createComponent(???);
 > >  if (component.status == Component.Ready) {
 > >         myStruct = component.createObject(parent, {"x": 100, "y": 100});
 > > }
 > >   
 > > What would ??? be?
 > 
 > If MyStruct is just a JS object, then just use JS. function MyStruct(){ 
 > return {"x": 100, "y": 100}; }; var myStruct = new MyStruct();
 > You only need createObject when you are creating an object defined in C++ or 
 > dynamic object from QML.
 
That is my rub here.  These are custom QML components that are being created in 
JS and then passed back into the C++ end of things.  The goal being I want to 
be able to write "plugins" for my app using JS instead of C++. So I am creating 
and manipulating custom types that are then used to manipulate and extend the 
C++.  I may be making this harder than it needs to be though.  I will give it a 
try with the non-gui QML components and see how far I get.

_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to