ListWidget itemClicked problem
I have just started learning Qt and have tried to write a simple little application which has a ListWidget and a LineEdit. When the user clicks an item in the ListWidget the text should appear in the LineEdit. It compiles and runs but when the item is clicked a segmentation fault occurs. I have searched through many examples but can't find one which is close enough to what I am trying to do to help. I would be grateful if someone could assist by pointing out where I have gone wrong. It's probably something very basic.
Code:
#ifndef MYDIALOG_H
#define MYDIALOG_H
#include <QDialog>
#include <QListWidgetItem>
{
Q_OBJECT
public:
public slots:
};
#endif
#include <QListWidgetItem>
MyDialog
::MyDialog(QWidget *parent
){
mainLayout->addWidget(staffList);
mainLayout->addWidget(result);
staffList->addItem("Fred Smith");
staffList->addItem("Billy Bloggs");
setWindowTitle(tr("Tone's Dialog"));
}
{
result->setText(item->text());
}
Re: ListWidget itemClicked problem
You have two result variables. One is a member of MyDialog, the second is a local variable in MyDialog constructor.
Re: ListWidget itemClicked problem
Thanks for your help Jacek.
I changed line31 from to and it now works.