3
3
#include " ui_MainWindow.h"
4
4
5
5
#include < QLabel>
6
+ #include < QTimer>
6
7
7
8
MainWindow::MainWindow (QWidget *parent) :
8
9
QMainWindow(parent),
9
10
ui(new Ui::MainWindow)
10
11
{
11
- ui->setupUi (this );
12
+ /* ui->setupUi(this);
12
13
13
14
// Create the dock manager. Because the parent parameter is a QMainWindow
14
15
// the dock manager registers itself as the central widget.
@@ -31,7 +32,67 @@ MainWindow::MainWindow(QWidget *parent) :
31
32
ui->menuView->addAction(DockWidget->toggleViewAction());
32
33
33
34
// 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);
35
96
}
36
97
37
98
MainWindow::~MainWindow ()
0 commit comments