Qt-Advanced-Docking-System使用说明_cdockmanager-CSDN博客
示例1:
cpp
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "DockManager.h"
#include "QtDock/DockAreaWidget.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
ads::CDockManager* m_pDockManger;
};
#endif // MAINWINDOW_H
cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//创建CDockManager对象
m_pDockManger=new ads::CDockManager(this);
this->setCentralWidget(m_pDockManger);
//创建CDockWidget窗口对象
ads::CDockWidget* pDockWidget1=new ads::CDockWidget("页面1");
//QLabel对象
QLabel *Label=new QLabel(pDockWidget1);
Label->setText("demo");
//添加容器
pDockWidget1->setWidget(Label);
//将pDockWidget1添入CDockManager页面布局中
m_pDockManger->addDockWidget(ads::RightDockWidgetArea,pDockWidget1);
}
MainWindow::~MainWindow()
{
delete ui;
}
![](https://img-blog.csdnimg.cn/direct/84905fc181ab492e9cf3204717076002.gif)
示例2:
cpp
//创建CDockManager对象
m_pDockManger=new ads::CDockManager(this);
this->setCentralWidget(m_pDockManger);
//创建CDockWidget窗口对象
ads::CDockWidget* pDockWidget1=new ads::CDockWidget("页面1");
//QLabel对象
QLabel *Label=new QLabel(pDockWidget1);
Label->setText("demo");
//添加容器
pDockWidget1->setWidget(Label);
//将pDockWidget1添入CDockManager页面布局中
m_pDockManger->addDockWidget(ads::RightDockWidgetArea,pDockWidget1);
ads::CDockWidget* pDockWidget2=new ads::CDockWidget("页面2");
QLabel *Label2=new QLabel(pDockWidget2);
Label2->setText("demo2");
pDockWidget2->setWidget(Label2);
m_pDockManger->addDockWidget(ads::LeftDockWidgetArea,pDockWidget2);
![](https://img-blog.csdnimg.cn/direct/91ee3f8e4a764516813f08df5e9561c6.gif)
示例3:
cpp
//创建CDockManager对象
m_pDockManger=new ads::CDockManager(this);
this->setCentralWidget(m_pDockManger);
//创建CDockWidget窗口对象
ads::CDockWidget* pDockWidget1=new ads::CDockWidget("页面1");
//QLabel对象
QLabel *Label=new QLabel(pDockWidget1);
Label->setText("demo");
//添加容器
pDockWidget1->setWidget(Label);
//将pDockWidget1添入CDockManager页面布局中
m_pDockManger->addDockWidget(ads::RightDockWidgetArea,pDockWidget1);
ads::CDockWidget* pDockWidget2=new ads::CDockWidget("页面2");
QLabel *Label2=new QLabel(pDockWidget2);
Label2->setText("demo2");
pDockWidget2->setWidget(Label2);
m_pDockManger->addDockWidget(ads::LeftDockWidgetArea,pDockWidget2);
ads::CDockWidget* pDockWidget3=new ads::CDockWidget("页面3");
QLabel *Label3=new QLabel(pDockWidget3);
Label3->setText("demo3");
pDockWidget3->setWidget(Label3);
m_pDockManger->addDockWidget(ads::TopDockWidgetArea,pDockWidget3);
![](https://img-blog.csdnimg.cn/direct/a5ba83cb598f4cf3b8fbb2b6edd63f07.gif)
示例4:
cpp
ads::CDockManager::setConfigFlag(ads::CDockManager::ActiveTabHasCloseButton, false);
![](https://img-blog.csdnimg.cn/direct/432ba5ebeb7e4d9b8406cf9d9c541b5b.png)
![](https://img-blog.csdnimg.cn/direct/30ef8ffb0c534de790a9253be12fa773.png)
cpp
ads::CDockManager::setConfigFlag(ads::CDockManager::ActiveTabHasCloseButton, true);
![](https://img-blog.csdnimg.cn/direct/d34d2dbfce8c4167bdc32da174024df4.png)
![](https://img-blog.csdnimg.cn/direct/9f6eaaf16ddb4b90a5a11adbd8997b7e.png)
不显示tab
pDockWidget1->setFeature(ads::CDockWidget::NoTab,true);
![](https://img-blog.csdnimg.cn/direct/65ffe0ac9a3e4a8dae26ad4edc2c70e5.png)
使用qss
cpp
pDockWidget1->setStyleSheet("background-color: rgb(224, 220, 216);");
![](https://img-blog.csdnimg.cn/direct/42207640a19c472a8a54411519ed53db.png)