33#include " ui_MainWindow.h"
44
55#include < QLabel>
6+ #include < QTimer>
67
78MainWindow::MainWindow (QWidget *parent) :
89 QMainWindow(parent),
910 ui(new Ui::MainWindow)
1011{
11- ui->setupUi (this );
12+ /* ui->setupUi(this);
1213
1314 // Create the dock manager. Because the parent parameter is a QMainWindow
1415 // the dock manager registers itself as the central widget.
@@ -31,7 +32,67 @@ MainWindow::MainWindow(QWidget *parent) :
3132 ui->menuView->addAction(DockWidget->toggleViewAction());
3233
3334 // Add the dock widget to the top dock widget area
34- m_DockManager->addDockWidget (ads::TopDockWidgetArea, DockWidget);
35+ m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);*/
36+
37+ ui->setupUi (this );
38+
39+ // Create the dock manager. Because the parent parameter is a QMainWindow
40+ // the dock manager registers itself as the central widget.
41+ m_DockManager1 = new ads::CDockManager (this );
42+
43+ // Create example content label - this can be any application specific
44+ // widget
45+ ads::CDockWidget* DockWidget;
46+ {
47+ QLabel* l = new QLabel ();
48+ l->setWordWrap (true );
49+ l->setAlignment (Qt::AlignTop | Qt::AlignLeft);
50+ l->setText (" Lorem ipsum dolor sit amet, consectetuer adipiscing elit. " );
51+
52+ // Create a dock widget with the title Label 1 and set the created label
53+ // as the dock widget content
54+ DockWidget = new ads::CDockWidget (" Label 1" );
55+ DockWidget->setWidget (l);
56+ }
57+
58+ ads::CDockWidget* DockWidget2;
59+ {
60+ QLabel* l = new QLabel ();
61+ l->setWordWrap (true );
62+ l->setAlignment (Qt::AlignTop | Qt::AlignLeft);
63+ l->setText (" Lorem ipsum dolor sit amet, consectetuer adipiscing elit. " );
64+
65+ // Create a dock widget with the title Label 1 and set the created label
66+ // as the dock widget content
67+ DockWidget2 = new ads::CDockWidget (" Label 2" );
68+ DockWidget2->setWidget (l);
69+ }
70+
71+
72+ // Add the toggleViewAction of the dock widget to the menu to give
73+ // the user the possibility to show the dock widget if it has been closed
74+ ui->menuView ->addAction (DockWidget->toggleViewAction ());
75+
76+ // Add the dock widget to the top dock widget area
77+ m_DockManager1->addDockWidget (ads::TopDockWidgetArea, DockWidget);
78+
79+
80+ auto funcRemoveFirstManager = [=]()
81+ {
82+ m_DockManager1->removeDockWidget (DockWidget);
83+
84+ delete m_DockManager1;
85+ m_DockManager1 = nullptr ;
86+ };
87+ QTimer::singleShot (3000 , funcRemoveFirstManager);
88+
89+ auto funcAddSecondManager = [=]()
90+ {
91+ m_DockManager2 = new ads::CDockManager (this );
92+
93+ m_DockManager2->addDockWidget (ads::TopDockWidgetArea, DockWidget);
94+ };
95+ QTimer::singleShot (5000 , funcAddSecondManager);
3596}
3697
3798MainWindow::~MainWindow ()
0 commit comments