Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I dynamically remove an element from a QML basic type list?

Tags:

qt

qml

I've successfully added elements using

list.push(element)

But how do I remove them? I've tried the following, but none of them seem to work.

list.pop()
list.pop_front()
list.remove()
list.remove(int)
list.remove(element)
like image 530
Hasan Al-Baghdadi Avatar asked Mar 04 '23 17:03

Hasan Al-Baghdadi


1 Answers

For people who always keep ending up on this page, like I did: I found a very hacky solution to remove an element from a list<QtObject>.

myList = Array.from(myList).filter(r => r !== elementIWant2Remove)

This is not very elegant, but it does the trick, if you need to remove an element.

like image 60
kevinKay Avatar answered Apr 06 '23 18:04

kevinKay