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? Thanks, -- Giuseppe D'Angelo | giuseppe.dang...@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
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development