Important: Please read the Qt Code of Conduct -

Component self destruction

  • Hello,
    I want to make the notification handling component.
    I want to make component for one notification (one row notification) which seems like this: (i removed some properties to make it smaller)


    Item {
        RowLayout {
            Text {
                id: notifID
            Text {
            Image {
                MouseArea {
                    id: ok_b



    NotificationForm {
        ok_b.onClicked: {
           //Here I need something like self destructor

    Then I want to add it into some listview where will be dynamicaly created these notifications components.
    And my question is:
    Is any posibility to make something like self destructor, that on "ok_b" is clicked that it will destroy itself and the listview automaticaly recognize that it is destroyed and remove it from listview

    Thanks for every response.

  • I think you need to read this section of the documentation: (see the "Deleting Objects Dynamically" section in particular).

    It certainly is possible to destroy objects by invoking .destroy() on the id or object var (but they need to have been created dynamically). Note also the "SelfDestroyingRect" example there of an object destroying itself.

Log in to reply