Clearing a QListWidget from private slot
I'm trying to clear the content of QListWidget using the following code:
as first line in a private slot and it's not working, before the code that adds items to the QListWidget. It simply adds to the content of QListWidget from the previous runs. For example, if Mike was displayed inside displayChildLWidget in first run, if run again to display Robert, it displays Mike followed by Robert instead of just Robert. If run again to display Joe, it dispalys
The same code QListWidget->clear() works fine inside other functions. Does QListWidget inside private slot have to be handled differently?
are you sure the slot is called?
insert qDebug() << "in slot" ;
to be sure.
The slot role is to display info and part of it is the QListWidget. The info is displayed so I have no doubt that the slot is called. The issue is only in the QListWidget; it adds to the info from the previous search.
If in the first Seach, I search for person A who has child "Mike", it displays Mike. If I search for person B who has child "Ryan", it displays Mike followed by Ryan instead of just Ryan
Hmm, i cannot reproduce it.
it clear the list even if slot is private
so I think you have some other bug :)
Found it :)
The QListWidget was used somewhere else......my mistake.