[Development] [QML]: Why can't create Q_GADGETs from QML ?

Simon Hausmann Simon.Hausmann at qt.io
Tue Jul 26 17:37:04 CEST 2016


Hi,


No objection per-se, but we'd have to figure out some details. For example declarative instantiation is

not an object, as the ownership rules do not comply with QObject. That would leave us with a JavaScript

constructor function, replacing Qt.point(...) for example. But then we'd have to comply with the namespace

rules, so we'd have


    qmlRegisterGadget<MyGadget>("MyModule", "ThatName", 1, 0);


and then


    import MyModule 1.0


and in expressions we'd have


    var g = new ThatName();


and the same for a namespaced import:


    import MyModule 1.0 as Foo


    var g = new Foo.ThatName();


It's a bit of work to do, but I don't see a problem in principle.


Simon

________________________________
From: Development <development-bounces+simon.hausmann=qt.io at qt-project.org> on behalf of BogDan Vatra <bogdan at kdab.com>
Sent: Tuesday, July 26, 2016 5:28:35 PM
To: development at qt-project.org
Subject: [Development] [QML]: Why can't create Q_GADGETs from QML ?

Hi,

Is there any reason why I can only use Q_GADGETs objects in QML, but not to
create them?

It will be nice if we can register Q_GADGETs  as qml creatable types too.

Cheers,
BogDan.
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160726/2085db10/attachment.html>


More information about the Development mailing list