Qt扩展-Advanced-Docking 简介及配置

Advanced-Docking 简介及配置

一、概述

Advanced-Docking 是类似QDockWidget 功能的多窗口停靠功能的库。很像visual stdio 的 停靠功能,这个库对于停靠使用的比较完善。很多的软件都使用了这个框架。

项目源地址:

https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System

使用案例入下:

  • Qt Creator
    从4.12版本开始,Qt Creator在其Qt Designer 中使用了该框架。
  • CETONI Elements
    CETONI Elements软件是一款全面的、基于插件的模块化实验室自动化软件,用于使用联合图形用户界面控制CETONI设备。该软件具有强大的脚本系统,可自动执行流程。这个软件也使用了这个视窗布局系统,使用户可以自由安排各种插件提供的所有视图和窗口。

二、项目结构

demo 目录和 example 目录下都是 项目的使用例子,我们就是从里面去参考这些示例即可。

src 目录是源代码目录,这个目录最终生成的是一个动态库和静态库,我们可以改变里面的ads.qrc 或者里面的 stylesheets 文件,达到定制这个布局系统的外观显示情况。

三、安装配置

我们打开源码编译后的 lib 目录下的内容,看我们需要使用哪种库引入即可。

同时把 src 里面的头文件给 复制到新的文件夹下


在header 文件夹下包括如下的文件。

四、代码测试

在 .pro 文件中添加,引入库的功能

cpp 复制代码
win32: LIBS += -L$$PWD/lib/ -lqtadvanceddocking

INCLUDEPATH += $$PWD/header
DEPENDPATH += $$PWD/header

测试源码

  • main.cpp
cpp 复制代码
#include "ADSUse.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    qDebug()<< QResource::registerResource("D:/Programs_Projects/Qt/GraduationDesign/MindCheck/Rescourses.rcc");

    QApplication::setStyle(QStyleFactory::create("Fusion"));
    ADSUse w;
    w.show();

    return a.exec();
}
  • ADSUse.h
cpp 复制代码
#ifndef ADSUSE_H
#define ADSUSE_H

#include <QWidget>
#include <DockManager.h>
#include <DockWidget.h>
#include <QLabel>

namespace Ui {
class ADSUse;
}

class ADSUse : public QWidget
{
    Q_OBJECT

public:
    explicit ADSUse(QWidget *parent = nullptr);
    ~ADSUse();

private:
    Ui::ADSUse *ui;

    // The main container for docking
    ads::CDockManager* m_DockManager;
};

#endif // ADSUSE_H
  • ADSUse.cpp
cpp 复制代码
#include "ADSUse.h"
#include "ui_ADSUse.h"

ADSUse::ADSUse(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ADSUse)
{
    ui->setupUi(this);

    // Create the dock manager after the ui is setup. Because the
    // parent parameter is a QMainWindow the dock manager registers
    // itself as the central widget as such the ui must be set up first.
    m_DockManager = new ads::CDockManager(this);

    // Create example content label - this can be any application specific
    // widget
    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
    ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1");
    DockWidget->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_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
}

ADSUse::~ADSUse()
{
    delete ui;
}
相关推荐
艾莉丝努力练剑11 小时前
【QT】信号与槽
linux·开发语言·c++·人工智能·windows·qt·qt5
小小码农Come on8 天前
QPushButton QSS(一):按钮常用qss
前端·javascript·css·qt5
习惯就好zz10 天前
[实战笔记] 从 Qt 5.12.9 跨越到 Qt 6.x 完美迁移指南 (Windows + VS)
windows·qt·msvc·qt5·qt6·迁移
艾莉丝努力练剑12 天前
【QT】Qt 从零上手:Hello World、项目文件与实战避坑指南
linux·运维·开发语言·c++·qt·继承·qt5
艾莉丝努力练剑18 天前
【QT】环境搭建收尾:认识Qt Creator
运维·开发语言·c++·人工智能·qt·qt creator·qt5
飞仔FeiZai25 天前
基于 Python 与 PyQt5 构建的特斯拉行车记录仪视频播放器
python·音视频·qt5
微尘hjx1 个月前
【目标检测软件 02】AirsPy 目标检测系统操作指南
人工智能·测试工具·yolo·目标检测·计算机视觉·目标跟踪·qt5
dllmayday2 个月前
QWidget上叠加半透明QML组件显示方案
开发语言·qt5
蓝天智能2 个月前
QT实战:Unix 系统内存异常排查
unix·qt5
GIS阵地2 个月前
Qt实现简易仪表盘
开发语言·c++·qt·pyqt·qgis·qt5·地理信息系统