PDA

View Full Version : [solved] Deleting element form QList does not change count()



KeineAhnung
4th May 2014, 22:28
Hi there,

I have put several tasks in a QList and when the task is done it shall be deleted form the list. If I do


iniTextList.removeFirst();
ui->iniList->setModel(new QStringListModel(iniTextList));

the first element disappears but iniList.count(); still gives me the initial number of elements. I guess removeFirst() does not "shrink" the list, the list still got n values just the first is empty and therefore not displayed. Is there a way to shorten the list?

[EDIT]
Sorry for the post! I just realized that I was deleting elements from the view and counted the elements of the underlying list.

anda_skoa
5th May 2014, 09:10
Just in case your code actually looks like that: this leaks string list models.

Cheers,
_