Segmentation Faul using addItem (QListWidget)
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.
Code:
class PlayerWidget
: public QWidget{
Q_OBJECT
public:
public slots:
private:
short numplayer;
};
Code:
PlayerWidget
::PlayerWidget(QWidget *parent
){
playerLayout->addWidget(playerLabel);
playerLayout->addWidget(playerView);
setLayout(playerLayout);
numplayer = 0;
playerView
->addItem
(QString("mooooooooo"));
// it works here!!!}
void PlayerWidget
::newPlayer(QString name
) {
//playerView->addItem(QString("name")); // not here
numplayer++;
}
newPlayer(QString) is a slot that is called by another widgets signal
Re: Segmentation Faul using addItem (QListWidget)
You could try with
QListWidgetItem ( QString("Woooo", playerView);
also how are you connecting the slots ?
Re: Segmentation Faul using addItem (QListWidget)
the mistake in ctor
must be
Code:
playerLabel
= new QLabel(tr
("Players:"));
becuase you already have playerLabel, playerView as class member variables.
Re: Segmentation Faul using addItem (QListWidget)
thank you spirit, it runs perfectly fine now!