Qt 鼠标点击穿透

以前的笔记, 转存到这里。

很遗憾qt没有这个函数
只好直接用x11shape的 XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, YXBanded)
焦点穿透的意思是所有鼠标键盘操作全部会穿透窗口到下方窗口。
有个 Qt::WA_TransparentForMouseEvents 可以对子部件实 现,而窗口本身不行。很多 osd 桌面歌词程序经常用

#ifdef Q_OS_LINUX
#include <X11/extensions/shape.h>
#endif
#ifdef Q_OS_WIN
#include <windows.h>
#endif
#ifdef Q_OS_LINUX
        XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput, 0,
                                0, NULL, 0, ShapeSet, YXBanded);
#endif
#ifdef Q_OS_WIN
        SetWindowLong(winId(), GWL_EXSTYLE, GetWindowLong(winId(), GWL_EXSTYLE) |
                      WS_EX_TRANSPARENT | WS_EX_LAYERED);
#endif

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值