网站服务器信息整体软装设计公司
网站服务器信息,整体软装设计公司,门户网站流程图,假建设银行网站1、概述 源码放在文章末尾
该项目实现了无边框窗口效果#xff0c;项目demo如下所示#xff1a;
项目代码如下所示#xff1a;
#include framelesswindow.h
#include QGuiApplication
#include QScreen#ifdef Q_OS_WIN
#include window…1、概述 源码放在文章末尾
该项目实现了无边框窗口效果项目demo如下所示
项目代码如下所示
#include framelesswindow.h
#include QGuiApplication
#include QScreen#ifdef Q_OS_WIN
#include windowsx.h
#endifFramelessWindow::FramelessWindow(QWindow *parent): QQuickWindow (parent)
{setFlags(flags() | Qt::FramelessWindowHint);#ifdef Q_OS_WINHWND hwnd reinterpret_castHWND(winId());LONG style GetWindowLong(hwnd, GWL_STYLE);SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
#endif//在这里改变默认移动区域//只有鼠标在移动区域内才能移动窗口connect(this, QQuickWindow::widthChanged, this, [this](int arg){m_moveArea.setWidth(arg - 16);});
}bool FramelessWindow::resizable() const
{return m_resizable;
}void FramelessWindow::setResizable(bool resizable)
{if (m_resizable ! resizable) {m_resizable resizable;emit resizableChanged();}
}bool FramelessWindow::nativeEvent(const QByteArray eventType, void *message, long *result)
{
#ifdef Q_OS_WINMSG* msg reinterpret_castMSG*(message);switch(msg-message) {case WM_NCCALCSIZE:{*result 0;return true;}case WM_NCHITTEST:{auto x GET_X_LPARAM(msg-lParam) - this-x();auto y GET_Y_LPARAM(msg-lParam) - this-y();auto w width();auto h height();if (m_resizable) {if (x 0 x 8 y 0 y 8) {*result HTTOPLEFT;return true;} else if (x 8 x (w - 8) y 0 y 8) {*result HTTOP;return true;} else if (x (w - 8) x w y 0 y 8) {*result HTTOPRIGHT;return true;} else if (x 0 x 8 y 8 y (h - 8)) {*result HTLEFT;return true;} else if (x (w - 8) x w y 8 y (h - 8)) {*result HTRIGHT;return true;} else if (x 0 x 8 y (h - 8) y h) {*result HTBOTTOMLEFT;return true;} else if (x 8 x (w - 8) y (h - 8) y h) {*result HTBOTTOM;return true;} else if (x (w - 8) x w y (h - 8) y h) {*result HTBOTTOMRIGHT;return true;}}if (m_moveArea.contains(x, y)){*result HTCAPTION;return true;} else {*result HTCLIENT;return true;}}default:break;}
#endifreturn QQuickWindow::nativeEvent(eventType, message, result);
}
源码下载
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/90362.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!