[Interest] Creating C++ objects in JavaScript with operator new

Richard Weickelt richard at weickelt.de
Tue Apr 16 13:39:16 CEST 2019


> You can also generate an object from Qml code directly: 
> Qt.createQmlObject()

I know, but I wanted to use operator new in order to achieve a better look &
feel. Please note that this is/was easily possible in Qt Script. See the
code snippets at
https://doc.qt.io/qt-5/qtscript-index.html#making-c-class-properties-available-in-qt-script

    var obj = new MyObject;
    obj.setEnabled( true );
    print( "obj is enabled: " + obj.isEnabled() );

> The new is lacking too much information to create the QObject properly.

What do you mean and why is that?


More information about the Interest mailing list