Re: QListWidget Insert Items
Aside from the fact that your code will blow up or exhibit undefined behavior if there happens to be more than 2 items in the stringlist that match "ABC" and that fact that you obviously haven't shown all of it (like, where is "name" defined, for instance? Must be those unimportant "..." lines) what you do show appears to be OK. If you get the same behavior using the addItem() method instead of insertItem(), then you are doing something somewhere else that messes up the list.
Re: QListWidget Insert Items
wallacesoh
In class .h file, instead of do this,
Code:
QList<QListWidgetItem*> item;
In .cpp file, do this
Code:
for(int i = 0; i < strList.size(); i++)
{
....
....
}
// Access the item using at operator like this item.at(i);
This way, you can add QListWidgetItems dynamically without need to predefine the number of items.