去除对话框边框 + 设置窗口可移动和透明+取消主窗口状态栏

    xiaoxiao2021-04-13  56

    1、去除对话框标题栏和边框 在构造函数里设置:     this->setWindowFlags(Qt::FramelessWindowHint); Qt::Dialog     (按照对话框的形式创建窗口--帮助/关闭) Qt::Window  (按照正常窗口的形式创建窗口--最大化/最小化/关闭) 2、窗口可移动 去除边框会造成窗口不可移动,可以通过以下方法来解决: 自定义鼠标按下事件和鼠标移动事件: void yourwindow::mousePressEvent(QMouseEvent *event) {      this->windowPos = this->pos();                // 获得部件当前位置      this->mousePos = event->globalPos();     // 获得鼠标位置      this->dPos = mousePos - windowPos;       // 移动后部件所在的位置 } void yourwindow::mouseMoveEvent(QMouseEvent *event) {      this->move(event->globalPos() - this->dPos); } 3、设置窗口透明 在构造函数中添加:     this->setAttribute(Qt::WA_TranslucentBackground); 4.取消主窗口状态栏 在主窗口ui文件右键单击,选中删除状态栏。
    转载请注明原文地址: https://ju.6miu.com/read-669360.html

    最新回复(0)