Bonjour à tous,
J'arrive pas à afficher un messageBox quand j'appuie sur le bouton "Valider".
Pour vous aider, un screen:
Voici mes fichiers:
main.cpp:
FenPrincipale.cpp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 #include <QApplication> #include <QtGui> #include "FenPrincipale.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); FenPrincipale fenetre; fenetre.show(); return app.exec(); }
FenPrincipale.h:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include "FenPrincipale.h" #include "ongletPromo.h" FenPrincipale::FenPrincipale() { // setMinimumSize(500, 350); setWindowIcon(QIcon("Logo.png")); setWindowTitle(tr("zGestionNotex")); QWidget *zonePromo = new QWidget(); OngletPromo ongletPromo(zonePromo); creerActions(); creerMenu(); creerBarresOutils(); setCentralWidget(zonePromo); }
OngletPromo.cpp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #ifndef HEADER_FENPRINCIPALE_INCLUDED #define HEADER_FENPRINCIPALE_INCLUDED #include <QtGui> class FenPrincipale : public QMainWindow { public: FenPrincipale(); private: void creerActions(); void creerMenu(); void creerBarresOutils(); private slots: void nouveauPromo(); void changerPromo(); void imprimer(); void editerEleves(); void editerMatieres(); void editerNotes(); void afficherEleves(); void afficherMatieres(); void afficherModules(); void afficherClassement(); private: QAction *actionNouveau; QAction *actionFichierBidon; QAction *actionImprimer; QAction *actionQuitter; QAction *actionEditerEleves; QAction *actionEditerMatieres; QAction *actionEditerNotes; QAction *actionEleves; QAction *actionMatieres; QAction *actionModules; QAction *actionClassement; }; #endif
OngletPromo.h:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include "ongletPromo.h" OngletPromo::OngletPromo(QWidget *zonePromo) { promo= new QSpinBox; promoNombre= new QSpinBox; QVBoxLayout *grr= new QVBoxLayout; QFormLayout *layoutInformations= new QFormLayout; layoutInformations->addRow("Promo: ",promo); layoutInformations->addRow("Nombre d'élèves : ",promoNombre); promo->setMinimum(2000); promo->setMaximum(2050); promoNombre->setMinimum(1); promoNombre->setMaximum(250); QHBoxLayout *layoutBouton=new QHBoxLayout; QPushButton *boutonValider= new QPushButton("Valider"); boutonValider->setIcon(QIcon("Valider.png")); layoutBouton->setAlignment(Qt::AlignRight); layoutBouton->addWidget(boutonValider); QGroupBox *promoInformations= new QGroupBox("Informations sur la Promo"); promoInformations->setLayout(layoutInformations); grr->addWidget(promoInformations); grr->addLayout(layoutBouton); zonePromo->setLayout(grr); connect(boutonValider,SIGNAL(clicked()),this,SLOT(demandeConfirmation())); } void OngletPromo::demandeConfirmation(QWidget *zonePromo) { QMessageBox::question(zonePromo, "Demande de confirmation", "Etes-vous sûr de bien vouloir enregistrer cette Promo?", QMessageBox::Yes | QMessageBox::No); }
Il n'a pas d'erreurs de compilation.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #ifndef ONGLETPROMO_H_INCLUDED #define ONGLETPROMO_H_INCLUDED #include <QtGui> class OngletPromo : public QMainWindow { public: OngletPromo(QWidget *zonePromo); private: private slots: void demandeConfirmation(QWidget *zonePromo); private: QSpinBox *promo; QSpinBox *promoNombre; }; #endif // ONGLETPROMO_H_INCLUDED
Merci encore![]()
Partager