Qt QListWidget erreure de segmentation Oo
Bonsoir ,
Je souhaite faire une application qui reçois un certains nombre de fichiers en entrées et qui apres traitement écrit un fichier de résultat.
J'ai donc ecris un objet qui me crée une fenetre avec une liste que l'on remplie via la fonction getopenfilenames();
Mais voila lorsque je compile , j'ai aucune erreure , mais lorsque j'execute le programme et que j'ouvre ma fenetre de selection de fichiers j'ai une erreure :
Code:
"erreure de segmentation"
qui provient de la ligne suivante a l'interieur de la methode void FenPrincipale::ouvrirfichier():
Code:
listWidget->insertItems(0,fichiers);
Quelqu'un peut m'expliquer ?
Une petite aide serait bien venue , je sèche la ....
voici le code de mon objet FenPrincipale :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| #include "FenPrincipale.h"
FenPrincipale::FenPrincipale() : QWidget()
{
QHBoxLayout *layoutGroupe1 = new QHBoxLayout;
QGroupBox *groupBox1 = new QGroupBox("Listes des fichiers", this);
QFormLayout *layoutForm1 = new QFormLayout;
QListWidget *listWidget = new QListWidget(this);
layoutForm1->addRow(listWidget);
groupBox1->setLayout(layoutForm1);
layoutGroupe1->addWidget(groupBox1);
QHBoxLayout *layoutGroupe2 = new QHBoxLayout;
progressBar = new QProgressBar(this);
progressBar->setObjectName(QString::fromUtf8("progressBar"));
progressBar->setGeometry(QRect(110, 190, 118, 23));
progressBar->setValue(50);
layoutGroupe2->addWidget(progressBar);
QHBoxLayout *layoutGroupe3 = new QHBoxLayout;
QPushButton *bouton1 = new QPushButton("Selectionner");
QPushButton *bouton2 = new QPushButton("Quitter");
layoutGroupe3->addWidget(bouton1);
layoutGroupe3->addWidget(bouton2);
QGridLayout *layoutPrincipal = new QGridLayout;
layoutPrincipal->addLayout(layoutGroupe1, 0, 0);
layoutPrincipal->addLayout(layoutGroupe2, 1, 0);
layoutPrincipal->addLayout(layoutGroupe3, 2, 0, Qt::AlignRight);
this->setLayout(layoutPrincipal);
QObject::connect(bouton1, SIGNAL(clicked()), this, SLOT(ouvrirfichier()));
QObject::connect(bouton2, SIGNAL(clicked()), qApp, SLOT(quit()));
}
void FenPrincipale::ouvrirfichier()
{
QStringList fichiers = QFileDialog::getOpenFileNames(this, "Ouvrir un fichier", QString(), "Tous fichiers texte (*.log *.txt *.cpp *.h)");
listWidget->insertItems(0,fichiers);
} |
et son header :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #ifndef FENPRINCIPALE_H_INCLUDED
#define FENPRINCIPALE_H_INCLUDED
#include <QtGui>
class FenPrincipale : public QWidget
{
Q_OBJECT
public:
FenPrincipale();
public slots:
void ouvrirfichier();
private:
QProgressBar *progressBar;
QListWidget *listWidget;
};
#endif // FENPRINCIPALE_H_INCLUDED |