Good evening everyone,

I try to create a form with a number of fields that are set by depending on a parameter.
So I wanted to do dynamic allocation of QLineEdit. I must say I am quite happy at first because the window displays properly with the correct number of fields.
However when I close the application, it does not close properly.
it says that the application encountered a problem, and i should send an error report.
Here's a snippet. H and. Cpp I have abbreviated for you.
Thank you for your valuable advice.


Qt Code:
  1. #ifndef CHAMPSVARIABLES_H
  2. #define CHAMPSVARIABLES_H
  3.  
  4. #include<QtGui>
  5.  
  6. class ChampsVariables : public QWidget
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. ChampsVariables();
  12. QLineEdit *LabelGenerique;
  13. QVBoxLayout *Layout;
  14. private:
  15.  
  16. private slots:
  17.  
  18. };
  19. #endif // CHAMPSVARIABLES_H
To copy to clipboard, switch view to plain text mode 

.cpp
Qt Code:
  1. #include"ChampsVariables.h"
  2.  
  3. ChampsVariables::ChampsVariables() : QWidget()
  4. {
  5. LabelGenerique = new QLineEdit[5];
  6. Layout = new QVBoxLayout;
  7.  
  8. for(int i=0;i<5;i++)
  9. {
  10. LabelGenerique[i].setText("");
  11. Layout->addWidget(&LabelGenerique[i]);
  12. }
  13.  
  14. setLayout(Layout);
  15.  
  16. QLayoutItem * item;
  17.  
  18. }
To copy to clipboard, switch view to plain text mode 

a simple main:
Qt Code:
  1. #include"ChampsVariables.h"
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5. QApplication app(argc, argv);
  6.  
  7. ChampsVariables fenetre;
  8. fenetre.show();
  9.  
  10.  
  11. return app.exec();
  12. }
To copy to clipboard, switch view to plain text mode