mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-26 14:29:02 +08:00
Fixed broken SimpleExample application
This commit is contained in:
parent
c6cf9487ba
commit
c44d0c87e3
@ -9,7 +9,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
/*ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// Create the dock manager. Because the parent parameter is a QMainWindow
|
// Create the dock manager. Because the parent parameter is a QMainWindow
|
||||||
// the dock manager registers itself as the central widget.
|
// the dock manager registers itself as the central widget.
|
||||||
@ -32,67 +32,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ui->menuView->addAction(DockWidget->toggleViewAction());
|
ui->menuView->addAction(DockWidget->toggleViewAction());
|
||||||
|
|
||||||
// Add the dock widget to the top dock widget area
|
// Add the dock widget to the top dock widget area
|
||||||
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);*/
|
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
||||||
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
// Create the dock manager. Because the parent parameter is a QMainWindow
|
|
||||||
// the dock manager registers itself as the central widget.
|
|
||||||
m_DockManager1 = new ads::CDockManager(this);
|
|
||||||
|
|
||||||
// Create example content label - this can be any application specific
|
|
||||||
// widget
|
|
||||||
ads::CDockWidget* DockWidget;
|
|
||||||
{
|
|
||||||
QLabel* l = new QLabel();
|
|
||||||
l->setWordWrap(true);
|
|
||||||
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
||||||
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
|
|
||||||
|
|
||||||
// Create a dock widget with the title Label 1 and set the created label
|
|
||||||
// as the dock widget content
|
|
||||||
DockWidget = new ads::CDockWidget("Label 1");
|
|
||||||
DockWidget->setWidget(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
ads::CDockWidget* DockWidget2;
|
|
||||||
{
|
|
||||||
QLabel* l = new QLabel();
|
|
||||||
l->setWordWrap(true);
|
|
||||||
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
||||||
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
|
|
||||||
|
|
||||||
// Create a dock widget with the title Label 1 and set the created label
|
|
||||||
// as the dock widget content
|
|
||||||
DockWidget2 = new ads::CDockWidget("Label 2");
|
|
||||||
DockWidget2->setWidget(l);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add the toggleViewAction of the dock widget to the menu to give
|
|
||||||
// the user the possibility to show the dock widget if it has been closed
|
|
||||||
ui->menuView->addAction(DockWidget->toggleViewAction());
|
|
||||||
|
|
||||||
// Add the dock widget to the top dock widget area
|
|
||||||
m_DockManager1->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
|
||||||
|
|
||||||
|
|
||||||
auto funcRemoveFirstManager = [=]()
|
|
||||||
{
|
|
||||||
m_DockManager1->removeDockWidget(DockWidget);
|
|
||||||
|
|
||||||
delete m_DockManager1;
|
|
||||||
m_DockManager1 = nullptr;
|
|
||||||
};
|
|
||||||
QTimer::singleShot(3000, funcRemoveFirstManager);
|
|
||||||
|
|
||||||
auto funcAddSecondManager = [=]()
|
|
||||||
{
|
|
||||||
m_DockManager2 = new ads::CDockManager(this);
|
|
||||||
|
|
||||||
m_DockManager2->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
|
||||||
};
|
|
||||||
QTimer::singleShot(5000, funcAddSecondManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -100,17 +40,3 @@ MainWindow::~MainWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
|
||||||
{
|
|
||||||
QMainWindow::closeEvent(event);
|
|
||||||
if (m_DockManager1)
|
|
||||||
{
|
|
||||||
m_DockManager1->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_DockManager2)
|
|
||||||
{
|
|
||||||
m_DockManager2->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -18,13 +18,9 @@ public:
|
|||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
ads::CDockManager* m_DockManager1;
|
ads::CDockManager* m_DockManager;
|
||||||
ads::CDockManager* m_DockManager2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user