From 85885624446558c2bf9fa27cb5bded9433943312 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 31 Oct 2023 15:12:23 +0100 Subject: Doc: Warn about slowness of createQmlObject() Pick-to: 6.6 6.5 Change-Id: Ie00d0df9bc8ad6106559ce0a66c91e0aaac81cfd Reviewed-by: Leena Miettinen Reviewed-by: Fabian Kosmale --- src/qml/doc/src/javascript/dynamicobjectcreation.qdoc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/qml/doc/src') diff --git a/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc b/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc index 29a4a67460..4342d3bada 100644 --- a/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc +++ b/src/qml/doc/src/javascript/dynamicobjectcreation.qdoc @@ -102,6 +102,12 @@ It is also possible to instantiate components without blocking via the \section2 Creating an Object from a String of QML +\warning Creating objects from a string of QML is extremely slow since the engine has to compile the +passed QML string every time you do it. Furthermore, it's very easy to produce invalid QML when +programmatically constructing QML code. It's much better to keep your QML components as separate +files and add properties and methods to customize their behavior than to produce new components by +string manipulation. + If the QML is not defined until runtime, you can create a QML object from a string of QML using the \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example: -- cgit v1.2.3