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)NotificationForm.ui.qml
Item { RowLayout { Text { id: notifID } Text { } Image { MouseArea { id: ok_b } } } }
and
Notification.qml
NotificationForm { ok_b.onClicked: { notifClass.notifyDone(notifID.text); //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 listviewThanks for every response.
-
I think you need to read this section of the documentation: http://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html (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.