Qt 不规则窗体 – 鼠标点击穿透

Windows API : SetWindowLong

        SetWindowLong是一个Windows API函数。该函数用来改变指定窗口的属性.函数也将指定的一个32位值设置在窗口的额外存储空间的指定偏移位置。

     函数定义:

LONG WINAPI SetWindowLong(
  _In_  HWND hWnd,
  _In_  int nIndex,
  _In_  LONG dwNewLong
);

    头文件:

#include<Winuser.h>

代码示例:

SetWindowLong((HWND)winId(), GWL_EXSTYLE, GetWindowLong((HWND)winId(), GWL_EXSTYLE) |
               WS_EX_TRANSPARENT | WS_EX_LAYERED);

Linux X11 API : XShapeCombineRectangles

        在 Linux/Unix 中,需要用到 X11 库函数:XShapeCombineRectangles。

函数定义:

void XShapeCombineRectangles (
        Display *dpy, 
        XID dest, 
        int destKind, 
        int xOff, 
        int yOff, 
        XRectangle *rects, 
        int n_rects, 
        int op, 
        int ordering);

头文件

#include <X11/extensions/shape.h>

代码示例:以 Linux 下 Qt 中使用为例

//头文件
#include <X11/extensions/shape.h>
#include <QtX11Extras/QX11Info>

//函数调用
XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput,0,0, NULL, 0, ShapeSet, YXBanded);

//.pro文件中添加
QT += x11extras
LIBS += -lX11 -lXext
扫描二维码关注公众号,回复: 2770714 查看本文章

猜你喜欢

转载自blog.csdn.net/lengyuezuixue/article/details/81516668