Guest User

Untitled

a guest
Apr 20th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include "mainwindow.h"
  2.  
  3. #include <QStackedLayout>
  4. #include <QStackedWidget>
  5. #include <QMdiArea>
  6. #include <QMdiSubWindow>
  7. #include <QAction>
  8. #include <QToolBar>
  9.  
  10. MainWindow::MainWindow(QWidget *parent)
  11.     : QMainWindow(parent)
  12. {
  13.     QVBoxLayout *root = new QVBoxLayout;
  14.     layout = new QStackedWidget;
  15.     QMdiArea *mdi1 = new QMdiArea;
  16.     mdi1->addSubWindow(new QMdiSubWindow);
  17.  
  18.     layout->addWidget(mdi1);
  19.  
  20.     QToolBar *toolBar = new QToolBar;
  21.     QAction *addWindow = new QAction("New Window", this);
  22.  
  23.     toolBar->addAction(addWindow);
  24.  
  25.     connect(addWindow, SIGNAL(triggered()), this, SLOT(addwindow()));
  26.  
  27.     root->addWidget(toolBar);
  28.     root->addWidget(layout);
  29.  
  30.     QWidget *w = new QWidget;
  31.     w->setLayout(root);
  32.  
  33.     setCentralWidget(w);
  34. }
  35.  
  36. MainWindow::~MainWindow()
  37. {
  38.  
  39. }
  40.  
  41. void MainWindow::addwindow()
  42. {
  43.     QMdiArea *a = (QMdiArea *) layout->currentWidget();
  44.     a->addSubWindow(new QMdiSubWindow);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment