Qt-Advanced-Docking-System使用说明_cdockmanager-CSDN博客
示例1:
#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
#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;
}
示例2:
//创建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);
示例3:
//创建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);
示例4:
ads::CDockManager::setConfigFlag(ads::CDockManager::ActiveTabHasCloseButton, false);
ads::CDockManager::setConfigFlag(ads::CDockManager::ActiveTabHasCloseButton, true);
不显示tab
pDockWidget1->setFeature(ads::CDockWidget::NoTab,true);
使用qss
pDockWidget1->setStyleSheet("background-color: rgb(224, 220, 216);");