MaFenetre::MaFenetre() : QWidget() { //We create all the Text Widgets of the window QLabel *label = new QLabel(this); label->setText("Welcome to Wine Quality Simulator !"); label->setFont(QFont("Times New Roman", 13)); label->setAlignment(Qt::AlignCenter); QLabel *label2 = new QLabel(this); label2->setPixmap(QPixmap("vinn.jpg")); label2->setAlignment(Qt::AlignCenter); QLabel *label3 = new QLabel(this); label3->setPixmap(QPixmap("top.jpg")); label3->setAlignment(Qt::AlignCenter); //The first Layout : the one for predict train = new QPushButton("&Train and Predict"); train->setToolTip("It will open a cmd command"); QFormLayout *layout1 = new QFormLayout; layout1->addWidget(train); QGroupBox *layoutt = new QGroupBox("Cheap wine or masterpiece? Click here to know !"); layoutt->setLayout(layout1); //The second Layout : the one to know if there are strange values. comp1 = new QDoubleSpinBox; comp2 = new QDoubleSpinBox; comp3 = new QDoubleSpinBox; comp4 = new QDoubleSpinBox; comp5 = new QDoubleSpinBox; comp6 = new QDoubleSpinBox; comp7 = new QDoubleSpinBox; comp8 = new QDoubleSpinBox; comp9 = new QDoubleSpinBox; comp10 = new QDoubleSpinBox; comp11 = new QDoubleSpinBox; generer = new QPushButton("&Are my values strange ?"); QFormLayout *definitionLayout = new QFormLayout; definitionLayout->addRow("&Fixed Acidity :", comp1); definitionLayout->addRow("&Volatile Acidity :", comp2); definitionLayout->addRow("&Citric Acid :", comp3); definitionLayout->addRow("&Residual Sugar :", comp4); definitionLayout->addRow("&Chlorides :", comp5); definitionLayout->addRow("&Free Sulfur Dioxide :", comp6); definitionLayout->addRow("&Total Sulfure Dioxide :", comp7); definitionLayout->addRow("&Density :", comp8); definitionLayout->addRow("&pH :", comp9); definitionLayout->addRow("&Sulphates :", comp10); definitionLayout->addRow("&Alcohol :", comp11); definitionLayout->addWidget(generer); QGroupBox *groupDefinition = new QGroupBox("Give us the required informations :"); groupDefinition->setLayout(definitionLayout); //Third Layout : Help and Leave quitter = new QPushButton("&Leave"); quitter->setToolTip("Goodbye !"); aider = new QPushButton("&Need some help ?"); aider->setToolTip("Looking for more info? Come here young padawan"); QHBoxLayout *boutonsLayout = new QHBoxLayout; boutonsLayout->setAlignment(Qt::AlignRight); boutonsLayout->addWidget(aider); boutonsLayout->addWidget(quitter); //The Main Layout : contains all three previous Layouts QVBoxLayout *layoutPrincipal = new QVBoxLayout; layoutPrincipal->addWidget(label); layoutPrincipal->addWidget(label3); layoutPrincipal->addWidget(layoutt); layoutPrincipal->addWidget(groupDefinition); layoutPrincipal->addWidget(label2); layoutPrincipal->addLayout(boutonsLayout); //Properties of the Window setLayout(layoutPrincipal); setWindowTitle("Wine Quality Simulator"); setWindowIcon(QIcon("icone.jpg")); resize(400, 450); // Connection of the buttons connect(quitter, SIGNAL(clicked()), qApp, SLOT(quit())); connect(generer, SIGNAL(clicked()), this, SLOT(genererCode())); connect(aider, SIGNAL(clicked()), this, SLOT(genererCodee())); connect(train, SIGNAL(clicked()), this, SLOT(ouvrirprog())); }
FenPrincipale::FenPrincipale() { // Groupe : Définition de la classe nom = new QLineEdit; classeMere = new QLineEdit; QFormLayout *definitionLayout = new QFormLayout; definitionLayout->addRow("&Nom :", nom); definitionLayout->addRow("Classe &mère :", classeMere); QGroupBox *groupDefinition = new QGroupBox("Définition de la classe"); groupDefinition->setLayout(definitionLayout); // Groupe : Options protections = new QCheckBox("Protéger le &header contre les inclusions multiples"); protections->setChecked(true); genererConstructeur = new QCheckBox("Générer un &constructeur par défaut"); genererDestructeur = new QCheckBox("Générer un &destructeur"); QVBoxLayout *optionsLayout = new QVBoxLayout; optionsLayout->addWidget(protections); optionsLayout->addWidget(genererConstructeur); optionsLayout->addWidget(genererDestructeur); QGroupBox *groupOptions = new QGroupBox("Options"); groupOptions->setLayout(optionsLayout); // Groupe : Commentaires auteur = new QLineEdit; date = new QDateEdit; date->setDate(QDate::currentDate()); role = new QTextEdit; QFormLayout *commentairesLayout = new QFormLayout; commentairesLayout->addRow("&Auteur :", auteur); commentairesLayout->addRow("Da&te de création :", date); commentairesLayout->addRow("&Rôle de la classe :", role); groupCommentaires = new QGroupBox("Ajouter des commentaires"); groupCommentaires->setCheckable(true); groupCommentaires->setChecked(false); groupCommentaires->setLayout(commentairesLayout); // Layout : boutons du bas (générer, quitter...) generer = new QPushButton("&Générer !"); quitter = new QPushButton("&Quitter"); QHBoxLayout *boutonsLayout = new QHBoxLayout; boutonsLayout->setAlignment(Qt::AlignRight); boutonsLayout->addWidget(generer); boutonsLayout->addWidget(quitter); // Définition du layout principal, du titre de la fenêtre, etc. QVBoxLayout *layoutPrincipal = new QVBoxLayout; layoutPrincipal->addWidget(groupDefinition); layoutPrincipal->addWidget(groupOptions); layoutPrincipal->addWidget(groupCommentaires); layoutPrincipal->addLayout(boutonsLayout); setLayout(layoutPrincipal); setWindowTitle("Zero Class Generator"); setWindowIcon(QIcon("icone.png")); resize(400, 450); // Connexions des signaux et des slots connect(quitter, SIGNAL(clicked()), qApp, SLOT(quit())); connect(generer, SIGNAL(clicked()), this, SLOT(genererCode())); }