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.
#ifndef CHAMPSVARIABLES_H
#define CHAMPSVARIABLES_H
#include<QtGui>
class ChampsVariables
: public QWidget{
Q_OBJECT
public:
ChampsVariables();
private:
private slots:
};
#endif // CHAMPSVARIABLES_H
#ifndef CHAMPSVARIABLES_H
#define CHAMPSVARIABLES_H
#include<QtGui>
class ChampsVariables : public QWidget
{
Q_OBJECT
public:
ChampsVariables();
QLineEdit *LabelGenerique;
QVBoxLayout *Layout;
private:
private slots:
};
#endif // CHAMPSVARIABLES_H
To copy to clipboard, switch view to plain text mode
.cpp
#include"ChampsVariables.h"
ChampsVariables
::ChampsVariables() : QWidget(){
for(int i=0;i<5;i++)
{
LabelGenerique[i].setText("");
Layout->addWidget(&LabelGenerique[i]);
}
setLayout(Layout);
}
#include"ChampsVariables.h"
ChampsVariables::ChampsVariables() : QWidget()
{
LabelGenerique = new QLineEdit[5];
Layout = new QVBoxLayout;
for(int i=0;i<5;i++)
{
LabelGenerique[i].setText("");
Layout->addWidget(&LabelGenerique[i]);
}
setLayout(Layout);
QLayoutItem * item;
}
To copy to clipboard, switch view to plain text mode
a simple main:
#include"ChampsVariables.h"
int main(int argc, char *argv[])
{
ChampsVariables fenetre;
fenetre.show();
return app.exec();
}
#include"ChampsVariables.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
ChampsVariables fenetre;
fenetre.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks