Destroy qml object
-
How can i instantly delete dynamically created objects?
-
Not instantly. You can invoke .destroy() on them, but that will merely queue them for deletion at a safe time (basically a deleteLater() from C++ land).
Technically, you could write your own function which gets exposed to QML via Q_INVOKABLE etc, something like: Q_INVOKABLE void deleteImmediatelyAndProbablyCrash(QObject *someObject) { delete someObject; } but it's a bad idea.
Cheers,
Chris. -
I want to empty all children of grid before adding next set of children. But .destroy() only delete the first set children after new children are added.
-
If you're talking about their visual appearance, why not set visible to false? That should stop them from taking up any space in the visual layout.
But that's a separate issue to the object lifetimes. Why is it important that you delete some before creating others? Are you on a really tight memory budget, or something?
Cheers,
Chris.