最近想做一个无边框的窗体,需要做窗体边框的阴影,在网上查了有很多中实现方法,我个人更加喜欢下面我所列出来的方法,
这个简单跟window系统的窗体的样子是一样的,但是不能跨平台,因为使用的window的系统函数实现的。
**一、标题需要添加的头文件**
#include <dwmapi.h>
#include <QLibrary>
**二、实现无边框窗体的缩放**
bool BaseFramelessWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
MSG* msg = reinterpret_cast<MSG*>(message);
switch(msg->message)
{
case WM_NCCALCSIZE://作用是使窗体变成无边框窗体
*result = 0; //如果没有这个步骤在缩放大小后出现标题栏
return true;
case WM_NCHITTEST:
int xPos = GET_X_LPARAM(msg->lParam) - this->frameGeometry()