[Development] QTCS2019 Notes from QtQml session

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Fri Nov 22 18:13:34 CET 2019

Il 22/11/19 16:49, Damian Ivanov ha scritto:
> I don't see this anywhere documented how this could be done using a singleton.

In 5.14 the solution is something along the lines of

> qmlRegisterSingletonInstance("Utils", 3, 14, "Obj", obj);

then in QML

> import Utils 3.14
> // use "Obj" instead of "obj"

In pre-5.14 the same is achieved by using qmlRegisterSingletonType with 
a callback (that returns the object + sets the ownership of the object 
to C++; definitely not as convenient). Usage from QML is identical.

> If I register it as singleton the application_engine doesn't find it
> findChild->

Could you please elaborate on this point?

Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20191122/5982a771/attachment.bin>

More information about the Development mailing list