#include <QApplication>
#include <QMainWindow>
#include <QDockWidget>
#include <QTextEdit>
#include <QToolBar>
#include <QAction>
int main(int argc, char *argv[])
{
// Application QMainWindow
mainWindow->setWindowTitle("MainWindow") ;
mainWindow
->setCentralWidget
(new QTextEdit("Hello Main World!")) ;
mainWindow->addDockWidget(Qt::RightDockWidgetArea, dock);
toolbar1
->addAction
(new QAction("FirstOne",
0)) ;
mainWindow->addToolBar(toolbar1) ;
toolbar2
->addAction
(new QAction("SecondOne",
0)) ;
mainWindow->addToolBar(toolbar2) ;
// another QMainWindow you want to embed
subMainWindow->setWindowTitle("sub-mainwindow") ;
subMainWindow
->setCentralWidget
(new QTextEdit("Hello Submain World!")) ;
toolbar3
->addAction
(new QAction("ThirdOne",
0)) ;
subMainWindow->addToolBar(toolbar3) ;
// embed :
dock->setWidget(subMainWindow) ;
subMainWindow->setParent(dock) ; // here
mainWindow->show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
#include <QApplication>
#include <QMainWindow>
#include <QDockWidget>
#include <QTextEdit>
#include <QToolBar>
#include <QAction>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// Application QMainWindow
QMainWindow *mainWindow = new QMainWindow;
mainWindow->setWindowTitle("MainWindow") ;
mainWindow->setCentralWidget(new QTextEdit("Hello Main World!")) ;
QDockWidget *dock = new QDockWidget;
mainWindow->addDockWidget(Qt::RightDockWidgetArea, dock);
QToolBar *toolbar1 = new QToolBar ;
toolbar1->addAction(new QAction("FirstOne",0)) ;
mainWindow->addToolBar(toolbar1) ;
QToolBar *toolbar2 = new QToolBar ;
toolbar2->addAction(new QAction("SecondOne",0)) ;
mainWindow->addToolBar(toolbar2) ;
// another QMainWindow you want to embed
QMainWindow *subMainWindow = new QMainWindow(0); // no parent
subMainWindow->setWindowTitle("sub-mainwindow") ;
subMainWindow->setCentralWidget(new QTextEdit("Hello Submain World!")) ;
QToolBar *toolbar3 = new QToolBar ;
toolbar3->addAction(new QAction("ThirdOne",0)) ;
subMainWindow->addToolBar(toolbar3) ;
// embed :
dock->setWidget(subMainWindow) ;
subMainWindow->setParent(dock) ; // here
mainWindow->show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks