Enable QML error when loading objects dynamically
Solved
QML and Qt Quick
-
I create a QML object on the fly in this way:
let component; let sprite; function createSprite() { component = Qt.createComponent("sprites/MySprite.qml"); sprite = component.createObject(window); }
During the development I didn't see the object anymore and no errors were reported in the console.
Removing this function and just declaring the object as usual:MySprite { }
leads to output some errors, so I had the change to correct them.
How to enable the usual error output even if the objects are loaded dynamically? -
@Mark81 This is clearly explained in the documentation (https://doc.qt.io/qt-5/qml-qtqml-qt.html#createComponent-method):
"The returned component's Component::status property indicates whether the component was successfully created. If the status is Component.Error, see Component::errorString() for an error description."