mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include <QLabel>
|
|
#include <QToolBar>
|
|
|
|
#include "DockAreaWidget.h"
|
|
#include "DockAreaTitleBar.h"
|
|
|
|
|
|
using namespace ads;
|
|
|
|
|
|
CMainWindow::CMainWindow(QWidget *parent) :
|
|
QMainWindow(parent),
|
|
ui(new Ui::CMainWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
// Add the toolbar
|
|
auto toolbar_ = addToolBar("Top Toolbar");
|
|
|
|
// Create the dock manager
|
|
ads::CDockManager::setConfigFlags(ads::CDockManager::DefaultOpaqueConfig);
|
|
ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasCloseButton,
|
|
false);
|
|
ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasUndockButton,
|
|
false);
|
|
ads::CDockManager::setConfigFlag(
|
|
ads::CDockManager::DockAreaHasTabsMenuButton, false);
|
|
auto DockManager = new ads::CDockManager(this);
|
|
|
|
// Create a dockable widget
|
|
QLabel *l1 = new QLabel();
|
|
l1->setWordWrap(true);
|
|
l1->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
l1->setText("Docking widget 1");
|
|
ads::CDockWidget *dockWidget1 = new ads::CDockWidget("Dock 1");
|
|
dockWidget1->setWidget(l1);
|
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, dockWidget1);
|
|
|
|
QLabel *l2 = new QLabel();
|
|
l2->setWordWrap(true);
|
|
l2->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
l2->setText("Docking widget 2");
|
|
ads::CDockWidget *dockWidget2 = new ads::CDockWidget("Dock 2");
|
|
dockWidget2->setWidget(l2);
|
|
DockManager->addDockWidget(ads::RightDockWidgetArea, dockWidget2);
|
|
|
|
// Add menu actions
|
|
ui->menuView->addAction(dockWidget1->toggleViewAction());
|
|
ui->menuView->addAction(dockWidget2->toggleViewAction());
|
|
toolbar_->addAction(dockWidget1->toggleViewAction());
|
|
toolbar_->addAction(dockWidget2->toggleViewAction());
|
|
}
|
|
|
|
|
|
CMainWindow::~CMainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
|
|
|