Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Removing items from the QListWidget
-
I use a list from which items are removed one at a time. The current list item is deleted. Deleting the second to last one always fails with the at () function error: index out of range.
Iterating through the list is ok, it reads and displays all the elements of the list correctly
There is more detailshow to fix it?
-
@BartoszT
How do you "Deleting the second to last one"?
Also by deleting currentItem()?
Deleting by iterating should be careful, the index and size are changing.
-
MY CODE works in signal button function
void MainWindow::on_pushButtonDELETE_clicked()
ListItem is deleted one by one for every button click
Deleting is two lines of MY CODE as you see above
-
Hi,
AFAIR, you should use takeItem before deleting it.