Skip to content

Commit c44d0c8

Browse files
Fixed broken SimpleExample application
1 parent c6cf948 commit c44d0c8

File tree

2 files changed

+3
-81
lines changed

2 files changed

+3
-81
lines changed

examples/simple/MainWindow.cpp

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MainWindow::MainWindow(QWidget *parent) :
99
QMainWindow(parent),
1010
ui(new Ui::MainWindow)
1111
{
12-
/*ui->setupUi(this);
12+
ui->setupUi(this);
1313

1414
// Create the dock manager. Because the parent parameter is a QMainWindow
1515
// the dock manager registers itself as the central widget.
@@ -32,85 +32,11 @@ MainWindow::MainWindow(QWidget *parent) :
3232
ui->menuView->addAction(DockWidget->toggleViewAction());
3333

3434
// Add the dock widget to the top dock widget area
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+
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
9636
}
9737

9838
MainWindow::~MainWindow()
9939
{
10040
delete ui;
10141
}
10242

103-
104-
void MainWindow::closeEvent(QCloseEvent *event)
105-
{
106-
QMainWindow::closeEvent(event);
107-
if (m_DockManager1)
108-
{
109-
m_DockManager1->deleteLater();
110-
}
111-
112-
if (m_DockManager2)
113-
{
114-
m_DockManager2->deleteLater();
115-
}
116-
}

examples/simple/MainWindow.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ class MainWindow : public QMainWindow
1818
explicit MainWindow(QWidget *parent = 0);
1919
~MainWindow();
2020

21-
protected:
22-
virtual void closeEvent(QCloseEvent *event) override;
23-
2421
private:
2522
Ui::MainWindow *ui;
26-
ads::CDockManager* m_DockManager1;
27-
ads::CDockManager* m_DockManager2;
23+
ads::CDockManager* m_DockManager;
2824
};
2925

3026
#endif // MAINWINDOW_H

0 commit comments

Comments
 (0)