hello,
can anyone help me out in deleting all the elements in a qlist??
i want to clear a qlist totally so that new data can be reloaded...
hello,
can anyone help me out in deleting all the elements in a qlist??
i want to clear a qlist totally so that new data can be reloaded...
use clear(). If you need to remove individual item use removeAt()
clear() will delete all the item.
Hi,
If you have pointers stored in the list you have to delete them manually:
Qt Code:
int iNum = qList.count(); for (int i=0; i<iNumElements; i++) delete (qList.takeAt(0)); //Always delete element 0To copy to clipboard, switch view to plain text mode
Òscar Llarch i Galán
No, it won't. It will only destroy pointers, not the objects behind them (same with removeAt() of course). Delete needs to be called explicitely on each item or, as already said, qDeleteAll() can be used.
Of course all that assumed one "deletes" objects behind pointers. If you have a list of objects then delete is not required as the destructor will be ran when using clear() or removeAt() (but I wouldn't call that "deleting" thus the whole post of mine).
Bookmarks