Solved Forwarding QML property to C++
-
A Little help here, I Intend using the "textDocument" property of the TextArea document in my C++ Code via QTextDocument.
I obviously don't want to make calls to search and transverse my object tree via rootObjects().at(index) and findChild() methods as i find them a lot less flexible and twingy to the eye.
Is there a cleaner and more flexible way to expose a QML Elements property to C++.
PS: I don't infer that calling C++ from QML using ** registertype**. I mean using exposing QML element property(s) to C++ -
i'm afraid findchild is the way to go: http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html
-
Thanks VRonin for the quick response.
-
@herlarbee
To add to @VRonin, I advise you to keep a reference to your object in aQPointer
, because QObject::findChild traverses theQObject
tree recursively and may be rather slow. -
@Kshegunov Thanks