#include "mainwindow.h" #include <QMenuBar> // menu bar required header file #include <QMenu> // menu #include <QAction> #include <QDebug> #include <QToolBar> #include <QPushButton> MainWindow :: MainWindow (QWidget * parent) : QMainWindow(parent) { // menu bar QMenuBar * mBar = menuBar (); // add menu QMenu * pFile mBar- => AddMenu ( " file " ); // add menu items to add action QAction * PNEW = pFile -> addAction ( " New " ) ; connect(pNew,&QAction::triggered,[=](){ qDebug () << " New is pressed !! " ; }); , pFile -> addSeparator (); // add the dividing line The QAction * = popen, pFile -> the addAction ( " open " ); // shortcut toolbar menu items QToolBar * toolBar = AddToolbar ( " toobar " ); // toolbar to add shortcuts toolBar -> addAction (PNEW); // to add a small toolbar controls, look good points, add a little button right here ...... QPushButton * b = new new QPushButton ( the this ); B -> the setText ( " ^ _ ^ " ); // add small control toolBar -> addWidget (B); // click the button, button display becomes 123 Connect (B, the QPushButton :: & clicked, [= ] ( ) { b->setText("123"); }); // status bar // core controls // floating window } MainWindow :: ~ MainWindow () { }
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); }; #endif // MAINWINDOW_H