Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mainwindow.h"
- #include <QStackedLayout>
- #include <QStackedWidget>
- #include <QMdiArea>
- #include <QMdiSubWindow>
- #include <QAction>
- #include <QToolBar>
- MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
- {
- QVBoxLayout *root = new QVBoxLayout;
- layout = new QStackedWidget;
- QMdiArea *mdi1 = new QMdiArea;
- mdi1->addSubWindow(new QMdiSubWindow);
- layout->addWidget(mdi1);
- QToolBar *toolBar = new QToolBar;
- QAction *addWindow = new QAction("New Window", this);
- toolBar->addAction(addWindow);
- connect(addWindow, SIGNAL(triggered()), this, SLOT(addwindow()));
- root->addWidget(toolBar);
- root->addWidget(layout);
- QWidget *w = new QWidget;
- w->setLayout(root);
- setCentralWidget(w);
- }
- MainWindow::~MainWindow()
- {
- }
- void MainWindow::addwindow()
- {
- QMdiArea *a = (QMdiArea *) layout->currentWidget();
- a->addSubWindow(new QMdiSubWindow);
- }
Advertisement
Add Comment
Please, Sign In to add comment