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
|
class fenetre : public QMainWindow{
Q_OBJECT
private:
QMenu * M_menu;
QMenu * M_sousMenu;
QAction * MA_affiche;
QAction * MA_quitter;
public:
fenetre();
~fenetre();
public slots:
void afficher();
};
fenetre::fenetre(){
//menu
M_menu = menuBar()->addMenu("&Fichier");
M_sousMenu = M_menu->addMenu("&Options");
MA_affiche = new QAction("Afficher", M_sousMenu);
MA_quitter = new QAction("Quitter", this);
M_menu->addAction(MA_quitter);
M_sousMenu->addAction(MA_affiche);
//connectiion menu
QObject::connect(MA_quitter, SIGNAL(triggered()), qApp, SLOT(quit()));
QObject::connect(MA_affiche, SIGNAL(triggered()), this, SLOT(afficher()));
}
fenetre::~fenetre(){
if(MA_quitter!=NULL)
delete MA_quitter;
if(MA_affiche!=NULL)
delete MA_affiche;
if(M_sousMenu!=NULL)
delete M_sousMenu;
if(M_menu!=NULL)
delete M_menu;
}
void fenetre::afficher(){
QMessageBox::information(0, QString("mon titre"), QString("affichage quelconque"));
} |
Partager