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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
// fichier dicto.h:
#ifndef DICTIO_H
#define DICTIO_H
#include<QLabel>
#include <QWidget>
#include<QLineEdit>
#include<QGridLayout>
#include<QVBoxLayout>
class dictio : public QWidget
{
Q_OBJECT
public:
explicit dictio(QWidget *parent = 0);
void build();
void setnbrd(int);
signals:
public slots:
protected :
QLabel *idl;
QLabel *noml;
QLabel *typel;
QLabel *longeurl;
int nbr_d;
QLineEdit **id;
QLineEdit **nom;
QLineEdit **type;
QLineEdit **longeur;
QGridLayout *grid1;
QGridLayout *grid2;
QGridLayout *grid3;
QGridLayout *grid4;
QHBoxLayout *box;
QHBoxLayout *label;
}
#endif // DICTIO_H
// fichier dicto.cpp
#include "dictio.h"
dictio::dictio(QWidget *parent) :
QWidget(parent)
{
this->setGeometry(10,10,600,700);
this->setVisible(true);
}
void dictio::build() {
this->id=new QLineEdit *[4];
this->nom=new QLineEdit *[4] ;
this->type=new QLineEdit *[4] ;
this->longeur=new QLineEdit *[4];
this->grid1=new QGridLayout;
this->grid2=new QGridLayout;
this->grid3=new QGridLayout;
this->grid4=new QGridLayout;
this->box=new QHBoxLayout;
this->noml=new QLabel("Nom");
this->idl=new QLabel("Identifiant");
this->typel=new QLabel("Type");
this->longeurl=new QLabel("Longeur");
this->grid1->addWidget(idl,0,0);
this->grid1->addWidget(noml,0,1);
this->grid1->addWidget(typel,0,2);
this->grid1->addWidget(longeurl,0,3);
for(int i=1;i<=nbr_d;i++){
int j=i-1;
id[j]=new QLineEdit;
nom[j]=new QLineEdit;
type[j]=new QLineEdit;
longeur[j]=new QLineEdit;
grid1->addWidget(id[j],i,0);
grid1->addWidget(nom[j],i,1);
grid1->addWidget(type[j],i,2);
grid1->addWidget(longeur[j],i,3);
}
this->setLayout(grid1);
// label=new QHBoxLayout;
// label->addWidget(idl);
// label->addWidget(noml);
// label->addWidget(typel);
// label->addWidget(longeurl);
// for(int i=0;i<nbr_d;i++){
// id[i]=new QLineEdit[nbr_d];
// nom[i]=new QLineEdit[nbr_d];
// type[i]=new QLineEdit[nbr_d];
// longeur[i]=new QLineEdit[nbr_d];
// }
// for(int i=0;i<=nbr_d;i++){
// grid1->addWidget(id[i],i,0);
// grid2->addWidget(nom[i],i,0);
// grid3->addWidget(type[i],i,0);
// grid4->addWidget(longeur[i],i,0);
// }
// QVBoxLayout *global=new QVBoxLayout;
// this->box->addLayout(grid1);
// this->box->addLayout(grid2);
// this->box->addLayout(grid3);
// this->box->addLayout(grid4);
// global->addLayout(label);
// global->addLayout(box);
// this->setLayout(global);
//}
}
void dictio::setnbrd(int n){
this->nbr_d=n;
}
// fichier main.cpp
#include<QApplication>
#include"dictio.cpp"
int main(int argc,char **argv ) {
QApplication a(argc,argv);
dictio *d=new dictio;
d->setnbrd(10);
d->build();
return a.exec();
} |
Partager