Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Destroy qml object

    QML and Qt Quick
    2
    4
    2667
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      ashwinrajeev last edited by

      How can i instantly delete dynamically created objects?

      1 Reply Last reply Reply Quote 0
      • C
        chrisadams last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • A
          ashwinrajeev last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • C
            chrisadams last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post