And this works? Hmm... seems odd, as you're allocating objects on the stack. They should get deleted upon returning from the function, causing those items to be removed from the list.

This should work too:

Qt Code:
  1. list_widget->addItem(new QListWidgetItem("item1"));
  2. list_widget->addItem(new QListWidgetItem("item2"));
  3. list_widget->addItem(new QListWidgetItem("item3"));
To copy to clipboard, switch view to plain text mode