用Mask去遮罩QWidget时候会发现背景是黑色的,这个是和系统有关系,如果在windows下绘制最好还要调用windows api :
1. override resizeEvent .
2. 添加如下lib :
LIBS += "F:\xxx\xxx\Gdi32.Lib"; (安装 windows SDK,并同时把User32.lib考进来)
3.添加window头文件:
#include "windows.h"
4. resizeEvent代码:
#ifdef VER_PLATFORM_WIN32_WINDOWS
HRGN hrgn = CreateRoundRectRgn(this->rect().x(),this->rect().y(),this->top->width(),(this->top->height()+mid->height()+bottom->height()),8,8);
SetWindowRgn(this->winId(),hrgn,true);
#endif
OK ,完成.