Hey there,
I am having trouble with QListWidget.. When I try to add an Item to it, a segmentation fault occurs..
Hope you guys can help me out.

Qt Code:
  1. class PlayerWidget : public QWidget
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. PlayerWidget(QWidget *parent = 0);
  7.  
  8. public slots:
  9. void newPlayer(QString);
  10.  
  11. private:
  12. QLabel *playerLabel;
  13. QListWidget *playerView;
  14.  
  15. short numplayer;
  16. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. PlayerWidget::PlayerWidget(QWidget *parent)
  2. : QWidget(parent)
  3. {
  4. QLabel *playerLabel = new QLabel(tr("Players:"));
  5. QListWidget *playerView = new QListWidget();
  6.  
  7. QVBoxLayout *playerLayout = new QVBoxLayout;
  8. playerLayout->addWidget(playerLabel);
  9. playerLayout->addWidget(playerView);
  10.  
  11. setLayout(playerLayout);
  12.  
  13. numplayer = 0;
  14. playerView->addItem(QString("mooooooooo")); // it works here!!!
  15. }
  16.  
  17. void PlayerWidget::newPlayer(QString name)
  18. {
  19. //playerView->addItem(QString("name")); // not here
  20. new QListWidgetItem(tr("mooo"), playerView); // nor here!
  21.  
  22. numplayer++;
  23. }
To copy to clipboard, switch view to plain text mode 

newPlayer(QString) is a slot that is called by another widgets signal